Javatpoint Logo
Javatpoint Logo

Pooling Layers

MaxPooling1D

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

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

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

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

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

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

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

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

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

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

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

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).







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA