如何将此函数重写为Keras CustomLayer类?
扩展名: How to Implement the Conv1DTranspose in keras?
def Conv1DTranspose(input_tensor, filters, kernel_size, strides=2,
padding='same', activation='relu'):
"""
input_tensor: tensor, with the shape (batch_size, time_steps, dims)
filters: int, output dimension, i.e. the output tensor will have the
shape of (batch_size, time_steps, filters)
kernel_size: int, size of the convolution kernel
strides: int, convolution step size
padding: 'same' | 'valid'
"""
x = Lambda(lambda x: K.expand_dims(x, axis=2))(input_tensor)
x = Conv2DTranspose(filters=filters, kernel_size=(kernel_size, 1),
strides=(strides, 1),
padding=padding, activation=activation)(x)
x = Lambda(lambda x: K.squeeze(x, axis=2))(x)
return x
似乎我的keras版本不包含Conv1DTranspose。 我猜应该有一个解决方法。预先谢谢!!