Pooling Layers in Deep Learning

MaxPooling1D

  1. keras.layers.MaxPooling1D(pool_size=2, strides=None, padding=‘valid’, data_format=‘channels_last’)

This layer performs max pooling operations for the temporal data.

Arguments

  • pool_size: It refers to an integer that represents the max pooling window’s size.
  • strides: It can be an integer or None that represents the factor through which it will downscale. For example., 2 will halve the input. If it is set to None, then it means it will default to the pool_size.
  • padding: It is case-sensitive, which is one of “valid” or “same”.
  • data_format: It can be a string of either “channels_last” or “channels_first”, which represents the order of input dimensions. Here the “channels_last” is the default format for temporal data in Keras, which links to the input shape (batch, steps, features). However, the “channels_first” is used to relate the input shape (batch, features, steps).

Input shape

If the data_format is “channels_first”, then the input shape of a 3D tensor is (batch_size, features, steps), else if data_format is “channels_last,” the input shape of a 3D tensor is (batch_size, steps, features).

Output shape

If the data_format is “channels_first”, the output shape of a 3D tensor will be (batch_size, features, downsampled_steps), else if the data_format is “channels_last” the output shape of a 3D tensor will be (batch_size, downsampled_steps, features).

MaxPooling2D

  1. keras.layers.MaxPooling2D(pool_size=(22), strides=None, padding=‘valid’, data_format=None)

The max pooling two-dimensional layer executes the max pooling operations for spatial data.

Arguments

  • pool_size: It refers to an integer or tuple of 2 integers, factors through which it will downscale (vertical, horizontal), such that (2, 2) will halve the input in both spatial dimensions. If we specify only one integer, then the similar length of the window will be utilized for each dimension.
  • strides: The stride value can be an integer, tuple of 2 integers, or None. If None is selected, then it will default to the pool_size.
  • padding: It is case-sensitive, which is one of “valid” or “same”.
  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. The “channels_last” corresponds to the input shape (batch, height, width, channels), whereas the “channels_first” relates to the input shape (batch, channels, height, width). It defaults to the image_data_format value that resides in Keras config at ~/.keras/keras.json. If you cannot find it in that folder, then it will be found in the “channels_last”.

Input shape

If the data_format is “channels_first”, then the input shape of a 4D tensor is (batch_size, channels, rows, cols), else if data_format is “channels_last” the input shape of a 4D tensor is (batch_size, rows, cols, channels).

Output shape

If the data_format is “channels_first”, the output shape of a 4D tensor will be (batch_size, channels, pooled_rows, pooled_cols), else if the data_format is “channels_last” the output shape of 4D tensor will be (batch_size, pooled_rows, pooled_cols, channels).

MaxPooling3D

  1. keras.layers.MaxPooling3D(pool_size=(222), strides=None, padding=‘valid’, data_format=None)

The max pooling three-dimensional layer executes the max pooling operation for the data such as spatial or Spatio-temporal, which is in the 3D.

Arguments

  • pool_size: It refers to a tuple of 3 integers, factors through which it will downscale (dim1, dim2, dim3), such that (2, 2, 2) will halve the size of a 3D input in every dimension.
  • strides: The stride value can be a tuple of 3 integers or None.
  • padding: It is case-sensitive, which is one of “valid” or “same”.
  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. Here the “channels_last” relates to the input shape (batch, spatial_dim1, spatial_dim2, spatial_dim3, channels) and the “channels_first” relates to the input shape (batch, channels, spatial_dim1, spatial_dim2, spatial_dim3). It defaults to the image_data_format value that resides in Keras config at ~/.keras/keras.json. If you cannot find it in that folder, then it will be found in the “channels_last”.
  • Input shape

If the data_format is “channels_first”, then the input shape of 5D tensor is (batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3), else if data_format is “channels_last” the input shape of 5D tensor is (batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels).

Output shape

If the data_format is “channels_first”, the output shape of a 5D tensor will be (batch_size, channels, pooled_dim1, pooled_dim2, pooled_dim3), else if the data_format is “channels_last” the output shape of a 5D tensor will be (batch_size, pooled_dim1, pooled_dim2, pooled_dim3, channels).

AveragePooling1D

  1. keras.layers.AveragePooling1D(pool_size=2, strides=None, padding=‘valid’, data_format=‘channels_last’)

This layer performs average pooling for temporal data.

Arguments

  • pool_size: It refers to an integer that depicts the max pooling window’s size.
  • strides: It can be an integer or None that represents the factor through which it will downscale. For example, 2 will halve the input. If None is selected, then it will default to the pool_size.
  • padding: It is case-sensitive, which is one of “valid” or “same”.
  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. Here the “channels_last” relates to the input shape (batch, steps, features), which is the default format for temporal data in Keras. However, the “channels_first” is used to relate the input shape (batch, features, steps).

Input shape

If the data_format is “channels_first”, then the input shape of a 3D tensor is (batch_size, features, steps), else if data_format is “channels_last,” the input shape of a 3D tensor is (batch_size, steps, features).

Output shape

If the data_format is “channels_first”, the output shape of a 3D tensor will be (batch_size, features, downsampled_steps), else if the data_format is “channels_last” the output shape of a 3D tensor will be (batch_size, downsampled_steps, features).

AveragePooling2D

  1. keras.layers.AveragePooling2D(pool_size=(22), strides=None, padding=‘valid’, data_format=None)

It performs average pooling for spatial data.

Arguments

  • pool_size: It refers to an integer or tuple of 2 integers, factors through which it will downscale (vertical, horizontal), such that (2, 2) will halve the input in both spatial dimensions. If we specify only one integer, then the similar length of the window will be used for both dimensions.
  • strides: The stride value can be an integer, tuple of 2 integers, or None. If None is selected, then it will default to the pool_size.
  • padding: It is case-sensitive, which is one of “valid” or “same”.
  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. Here the “channels_last” relates to the input shape (batch, height, width, channels), and the “channels_first” relates to the input shape (batch, channels, height, width). It defaults to the image_data_format value that is found in Keras config at ~/.keras/keras.json. If you cannot find it in that folder, then it is residing at “channels_last”.

Input shape

If the data_format is “channels_first”, then the input shape of a 4D tensor is (batch_size, channels, rows, cols), else if data_format is “channels_last” the input shape of a 4D tensor is (batch_size, rows, cols, channels).

Output shape

If the data_format is “channels_first”, the output shape of a 4D tensor will be (batch_size, channels, pooled_rows, pooled_cols), else if the data_format is “channels_last” the output shape of 4D tensor will be (batch_size, pooled_rows, pooled_cols, channels).

AveragePooling3D

  1. keras.layers.AveragePooling3D(pool_size=(222), strides=None, padding=‘valid’, data_format=None)

It performs average pooling operation for 3D data such as Spatio-temporal or spatial.

Arguments

  • pool_size: It refers to a tuple of 3 integers, factors through which it will downscale (dim1, dim2, dim3), such that (2, 2, 2) will halve the size of a 3D input in every dimension.
  • strides: The stride value can be a tuple of 3 integers or None.
  • padding: It is case-sensitive, which is one of “valid” or “same”.
  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. Here the “channels_last” relates to the input shape (batch, spatial_dim1, spatial_dim2, spatial_dim3, channels) and the “channels_first” relates to the input shape (batch, channels, spatial_dim1, spatial_dim2, spatial_dim3). It defaults to the image_data_format value that is found in Keras config at ~/.keras/keras.json. If you cannot find it in that folder, then it is residing at “channels_last”.

Input shape

If the data_format is “channels_first”, then the input shape of 5D tensor is (batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3), else if data_format is “channels_last” the input shape of 5D tensor is (batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels).

Output shape

If the data_format is “channels_first”, the output shape of a 5D tensor will be (batch_size, channels, pooled_dim1, pooled_dim2, pooled_dim3), else if the data_format is “channels_last” the output shape of a 5D tensor will be (batch_size, pooled_dim1, pooled_dim2, pooled_dim3, channels).

GlobalMaxPooling1D

  1. keras.layers.GlobalMaxPooling1D(data_format=‘channels_last’)

It performs global max pooling operations for temporal data.

Arguments

  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. Here the “channels_last” relates to the input shape (batch, steps, features), which is the default format for temporal data in Keras. However, the “channels_first” is used to relate the input shape (batch, features, steps). It defaults to the image_data_format value that is found in Keras config at ~/.keras/keras.json. If you cannot find it in that folder, then it is residing at “channels_last”.

Input shape

If the data_format is “channels_first”, then the input shape of a 3D tensor is (batch_size, features, steps), else if data_format is “channels_last,” the input shape of a 3D tensor is (batch_size, steps, features).

Output shape

It is a 2D tensor with shape (batch_size, features).

GlobalAveragePooling1D

  1. keras.layers.GlobalAveragePooling1D(data_format=‘channels_last’)

It performs global average pooling operations for temporal data.

Arguments

  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. Here the “channels_last” relates to the input shape (batch, steps, features), which is the default format for temporal data in Keras. However, the “channels_first” is used to relate the input shape (batch, features, steps).

Input shape

If the data_format is “channels_first”, then the input shape of a 3D tensor is (batch_size, features, steps), else if data_format is “channels_last,” the input shape of a 3D tensor is (batch_size, steps, features).

Output shape

It is a 2D tensor with shape (batch_size, features).

GlobalMaxPooling2D

  1. keras.layers.GlobalMaxPooling2D(data_format=None)

It performs global max pooling operations for spatial data.

Arguments

  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. Here the “channels_last” relates to the input shape (batch, height, width, channels), and “channels_first” is used to relate the input shape (batch, channels, height, width). It defaults to the image_data_format value that is found in Keras config at ~/.keras/keras.json. If you cannot find it in that folder, then it is residing at “channels_last”.

Input shape

If the data_format is “channels_first”, then the input shape of a 4D tensor is (batch_size, channels, rows, cols), else if data_format is “channels_last” the input shape of a 4D tensor is (batch_size, rows, cols, channels).

Output shape

It is a 2D tensor with shape (batch_size, features).

GlobalAveragePooling2D

  1. keras.layers.GlobalAveragePooling2D(data_format=None)

It performs global average pooling operations for spatial data.

Arguments

  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. Here the “channels_last” relates to the input shape (batch, height, width, channels), and “channels_first” is used to relate the input shape (batch, channels, height, width). It defaults to the image_data_format value that is found in Keras config at ~/.keras/keras.json. If you cannot find it in that folder, then it is residing at “channels_last”.

Input shape

If the data_format is “channels_first”, then the input shape of a 4D tensor is (batch_size, channels, rows, cols), else if data_format is “channels_last” the input shape of a 4D tensor is (batch_size, rows, cols, channels).

Output shape

It is a 2D tensor with shape (batch_size, features).

GlobalMaxPooling3D

  1. keras.layers.GlobalMaxPooling3D(data_format=None)

It performs global max pooling operation for three-dimensional data.

Arguments

  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. Here the “channels_last” relates to the input shape (batch, spatial_dim1, spatial_dim2, spatial_dim3, channels), and “channels_first” is used to relate the input shape (batch, channels, spatial_dim1, spatial_dim2, spatial_dim3). It defaults to the image_data_format value that is found in Keras config at ~/.keras/keras.json. If you cannot find it in that folder, then it is residing at “channels_last”.

Input shape

If the data_format is “channels_first”, then the input shape of 5D tensor is (batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3), else if data_format is “channels_last” the input shape of 5D tensor is (batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels).

Output shape

It is a 2D tensor with shape (batch_size, features).

GlobalAveragePooling3D

  1. keras.layers.GlobalAveragePooling3D(data_format=None)

It performs operations of global average pooling for 3D data.

Arguments

  • data_format: It can be a string of either “channels_last” or “channels_first”, which is the order of input dimensions. Here the “channels_last” relates to the input shape (batch, spatial_dim1, spatial_dim2, spatial_dim3, channels), and “channels_first” is used to relate the input shape (batch, channels, spatial_dim1, spatial_dim2, spatial_dim3). It defaults to the image_data_format value that is found in Keras config at ~/.keras/keras.json. If you cannot find it in that folder, then it is residing at “channels_last”.

Input shape

If the data_format is “channels_first”, then the input shape of 5D tensor is (batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3), else if data_format is “channels_last” the input shape of 5D tensor is (batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels).

Output shape

It is a 2D tensor with shape (batch_size, features).

This article has been published from the source link without modifications to the text. Only the headline has been changed.

Source link