我是DL的新手,并将千层面CNN重新编码为Keras(TF)
该层的一部分是Conv1D
,然后是Maxout
,其特征为maxout
Maxout函数已从keras2.0中删除
我参考了stack overflow和git-hub 编写自定义lambda函数
def Maxout(x, num_unit=None):
input_shape = x.get_shape().as_list()
ch = input_shape[-1]
num_unit = int(ch / 2)
assert ch is not None and ch % num_unit == 0
x = K.backend.reshape(x, (-1, ch // int(num_unit) , int(num_unit)))
x = K.backend.max(x, axis=1,keepdims=True)
input_tensor = Input(shape=(128,32),name = 'input')
conv4= (Conv1D(64, kernel_size=5, strides=1,
padding = 'same',
name = 'conv4',
input_shape=(128,32)))(maxpool1)
output = Lambda(Maxout,name='maxout')(conv4)
model = Model(inputs=input_tensor, outputs=output)
print(model.summary())
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input (InputLayer) (None, 128, 32) 0
_________________________________________________________________
conv4 (Conv1D) (None, 128, 64) 20544
_________________________________________________________________
maxout (Lambda) (None, 1, 32) 0
=================================================================
我期望从输入:(None,128,64)到输出:(None,128,32)的Maxout层
如何在128,32中获得输出的形状?