AveragePooling3D
classkeras.layers.AveragePooling3D(
pool_size, strides=None, padding="valid", data_format=None, name=None, **kwargs
)
三维数据的平均池化操作(空间或时空).
沿其空间维度(深度、高度和宽度)对输入进行下采样,通过在输入窗口(大小由 pool_size
定义)上取平均值来对输入的每个通道进行下采样.窗口沿每个维度按 strides
移动.
参数:
pool_size: 整数或 3 个整数的元组,用于缩小的因子(dim1, dim2, dim3).如果只指定一个整数,则所有维度将使用相同的窗口长度.
strides: 整数或 3 个整数的元组,或 None.步幅值.如果为 None,则默认为 pool_size
.如果只指定一个整数,则所有维度将使用相同的步幅大小.
padding: 字符串,可以是 "valid"
或 "same"
(不区分大小写)."valid"
表示不填充."same"
会导致在输入的左右或上下均匀填充,使得输出具有与输入相同的高度/宽度维度.
data_format: 字符串,可以是 "channels_last"
或 "channels_first"
.输入中维度的顺序."channels_last"
对应于形状为 (batch, spatial_dim1, spatial_dim2, spatial_dim3, channels)
的输入,而 "channels_first"
对应于形状为 (batch, channels, spatial_dim1, spatial_dim2, spatial_dim3)
的输入.它默认为在 ~/.keras/keras.json
中找到的 image_data_format
值.如果你从未设置过它,那么它将是 "channels_last"
.
输入形状:
data_format="channels_last"
:
形状为 (batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)
的 5D 张量data_format="channels_first"
:
形状为 (batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)
的 5D 张量输出形状:
data_format="channels_last"
:
形状为 (batch_size, pooled_dim1, pooled_dim2, pooled_dim3, channels)
的 5D 张量data_format="channels_first"
:
形状为 (batch_size, channels, pooled_dim1, pooled_dim2, pooled_dim3)
的 5D 张量示例:
depth = 30
height = 30
width = 30
channels = 3
inputs = keras.layers.Input(shape=(depth, height, width, channels))
layer = keras.layers.AveragePooling3D(pool_size=3)
outputs = layer(inputs) # 形状: (batch_size, 10, 10, 10, 3)