tf.keras.layers.MaxPool2D——tf2.1 Document

参考自tf2.1官方文档:
https://www.tensorflow.org/api_docs/python/tf/keras/layers/MaxPool2D


Max pooling operation for spatial data.
对空间数据进行 Max pooling 操作

tf.keras.layers.MaxPool2D(
    pool_size=(2, 2), strides=None, padding='valid', data_format=None, **kwargs
)




Arguments:

  • pool_size: integer or tuple of 2 integers, factors by which to downscale (vertical, horizontal).
    (2, 2) will halve the input in both spatial dimension.
    If only one integer is specified, the same window length will be used for both dimensions.

  • pool_size: 一个整数或者二元元组,用于指定pooling kernel的大小。
    默认为(2, 2),会使输入在两个维度上减半。
    如果只传入一个整数,kernel(window)长度在两个维度上相等(就是window的长宽相等)。

  • strides: Integer, tuple of 2 integers, or None. Strides values. If None, it will default to pool_size.

  • strides: 一个整数或者二元元组或者None,指定步长值。如果为None,它将被指定为pool_size

  • padding: One of “valid” or “same” (case-insensitive).

  • padding: “valid” 或者 “same”(不区分大小写)

  • data_format: A string, one of channels_last (default) or channels_first.
    The ordering of the dimensions in the inputs.
    channels_last corresponds to inputs with shape (batch, height, width, channels) while channels_first corresponds to inputs with shape (batch, channels, height, width).
    It defaults to the image_data_format value found in your Keras config file at ~/.keras/keras.json.
    If you never set it, then it will be “channels_last”.

  • data_format: 字符串,'channels_last' (default)或channels_first
    指定输入维度的次序。
    'channels_last' 指定输入的形状为(batch, height, width, channels)
    channels_first指定输入的形状为(batch, channels, height, width)
    其默认设置在配置文件~/.keras/keras.json中的image_data_format
    若在该文件中没有设置,则将为'channels_last'




Input shape:

  • If data_format=‘channels_last’: 4D tensor with shape (batch_size, rows, cols, channels).
  • 如果 data_format=‘channels_last’,则输入4D张量shape为(batch_size, rows, cols, channels)
  • If data_format=‘channels_first’: 4D tensor with shape (batch_size, channels, rows, cols).
  • 如果 data_format=‘channels_first’,则输入4D张量shape为(batch_size, channels, rows, cols)




Output shape:

  • If data_format=‘channels_last’: 4D tensor with shape (batch_size, pooled_rows, pooled_cols, channels).
  • 如果 data_format=‘channels_last’,则输出4D张量shape为(batch_size, pooled_rows, pooled_cols, channels)
  • If data_format=‘channels_first’: 4D tensor with shape (batch_size, channels, pooled_rows, pooled_cols).
  • 如果 data_format=‘channels_first’,则输出4D张量shape为(batch_size, channels, pooled_rows, pooled_cols, )
原创文章 66 获赞 14 访问量 9087

猜你喜欢

转载自blog.csdn.net/HaoZiHuang/article/details/105214504