| View source on GitHub | 
Global max pooling operation for spatial data.
tf.keras.layers.GlobalMaxPool2D(
    data_format=None, keepdims=False, **kwargs
)
  input_shape = (2, 4, 5, 3) x = tf.random.normal(input_shape) y = tf.keras.layers.GlobalMaxPool2D()(x) print(y.shape) (2, 3)
| Args | |
|---|---|
| data_format | A string, one of channels_last(default) orchannels_first. The ordering of the dimensions in the inputs.channels_lastcorresponds to inputs with shape(batch, height, width, channels)whilechannels_firstcorresponds to inputs with shape(batch, channels, height, width). It defaults to theimage_data_formatvalue found in your Keras config file at~/.keras/keras.json. If you never set it, then it will be "channels_last". | 
| keepdims | A boolean, whether to keep the spatial dimensions or not. If keepdimsisFalse(default), the rank of the tensor is reduced for spatial dimensions. IfkeepdimsisTrue, the spatial dimensions are retained with length 1. The behavior is the same as fortf.reduce_maxornp.max. | 
data_format='channels_last': 4D tensor with shape (batch_size, rows, cols, channels).data_format='channels_first': 4D tensor with shape (batch_size, channels, rows, cols).keepdims=False: 2D tensor with shape (batch_size, channels).keepdims=True: data_format='channels_last': 4D tensor with shape (batch_size, 1, 1, channels)
data_format='channels_first': 4D tensor with shape (batch_size, channels, 1, 1)
    © 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
    https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/keras/layers/GlobalMaxPool2D