GlobalMaxPooling2D 类tf_keras.layers.GlobalMaxPooling2D(data_format=None, keepdims=False, **kwargs)
用于空间数据的全局最大池化操作。
示例
>>> input_shape = (2, 4, 5, 3)
>>> x = tf.random.normal(input_shape)
>>> y = tf.keras.layers.GlobalMaxPooling2D()(x)
>>> print(y.shape)
(2, 3)
参数
tf.reduce_max 或 `np.max` 相同。输入形状
data_format='channels_last':形状为 (batch_size, rows, cols, channels) 的 4D 张量。data_format='channels_first':形状为 (batch_size, channels, rows, cols) 的 4D 张量。输出形状
keepdims=False:形状为 (batch_size, channels) 的 2D 张量。keepdims=Truedata_format='channels_last':形状为 (batch_size, 1, 1, channels) 的 4D 张量data_format='channels_first':形状为 (batch_size, channels, 1, 1) 的 4D 张量