AveragePooling3D
类keras.layers.AveragePooling3D(
pool_size, strides=None, padding="valid", data_format=None, name=None, **kwargs
)
用于三维数据(空间或时空)的平均池化操作。
通过对输入窗口(大小由pool_size
定义)内的每个通道取平均值,沿其空间维度(深度、高度和宽度)对输入进行下采样。窗口沿每个维度移动strides
。
参数
pool_size
。如果只指定一个整数,则所有维度都将使用相同的步长大小。"valid"
或"same"
(不区分大小写)。"valid"
表示不填充。"same"
会导致在输入的左侧/右侧或上下方进行均匀填充,以便输出具有与输入相同的宽度/高度维度。"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/keras.json
)中找到的image_data_format
值。如果您从未设置它,则它将为"channels_last"
。输入形状
data_format="channels_last"
:5D 张量,形状为:(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)
data_format="channels_first"
:5D 张量,形状为:(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)
输出形状
data_format="channels_last"
:5D 张量,形状为:(batch_size, pooled_dim1, pooled_dim2, pooled_dim3, channels)
data_format="channels_first"
:5D 张量,形状为:(batch_size, channels, pooled_dim1, pooled_dim2, pooled_dim3)
示例
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) # Shape: (batch_size, 10, 10, 10, 3)