GlobalMaxPooling1D
类keras.layers.GlobalMaxPooling1D(data_format=None, keepdims=False, **kwargs)
针对时序数据的全局最大池化操作。
参数
"channels_last"
或 "channels_first"
。输入维度的顺序。"channels_last"
对应输入形状为 (batch, steps, features)
,而 "channels_first"
对应输入形状为 (batch, features, steps)
。它默认为你的 Keras 配置文件 ~/.keras/keras.json
中 image_data_format
的值。如果你从未设置过,则默认为 "channels_last"
。keepdims
为 False
(默认值),则张量的秩会因空间维度而降低。如果 keepdims
为 True
,则时序维度会保留长度 1。其行为与 tf.reduce_mean
或 np.mean
相同。输入形状
data_format='channels_last'
:形状为 (batch_size, steps, features)
的 3D 张量data_format='channels_first'
:形状为 (batch_size, features, steps)
的 3D 张量输出形状
keepdims=False
:形状为 (batch_size, features)
的 2D 张量。keepdims=True
: - 如果 data_format="channels_last"
:形状为 (batch_size, 1, features)
的 3D 张量 - 如果 data_format="channels_first"
:形状为 (batch_size, features, 1)
的 3D 张量示例
>>> x = np.random.rand(2, 3, 4)
>>> y = keras.layers.GlobalMaxPooling1D()(x)
>>> y.shape
(2, 4)