如果您的输入具有以下维度:(None, timestamps, features),您可以简单地用其他维度置换深度,应用标准池化,然后置换回原始维度。
举个例子...如果您的网络接受输入白色形状(None, 20, 99),您可以简单地执行以下操作来获得深度池:
inp = Input((20,99))
depth_pool = Permute((2,1))(inp)
depth_pool = AveragePooling1D(3)(depth_pool)
depth_pool = Permute((2,1))(depth_pool)
m = Model(inp, depth_pool)
m.summary()
总结:
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_4 (InputLayer) [(None, 20, 99)] 0
_________________________________________________________________
permute_4 (Permute) (None, 99, 20) 0
_________________________________________________________________
average_pooling1d_3 (Average (None, 33, 20) 0
_________________________________________________________________
permute_5 (Permute) (None, 20, 33) 0
=================================================================
输出的形状为(None, 20, 33)
如果您的输入具有以下维度:(None, features, timestamps),您只需在图层中设置 data_format='channels_first'
inp = Input((20,99))
depth_pool = AveragePooling1D(3, data_format='channels_first')(inp)
m = Model(inp, depth_pool)
m.summary()
总结:
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_9 (InputLayer) [(None, 20, 99)] 0
_________________________________________________________________
average_pooling1d_7 (Average (None, 20, 33) 0
=================================================================
输出的形状为(None, 20, 33)