在ConvLSTM模型中添加Maxpooling层时出错

时间:2019-05-21 04:40:07

标签: python keras

我想在ConvLSTM2D层之后添加Maxpooling1D层。在convlstm2d层之后添加maxpooling层有意义吗?

我的数据集的维度是

samples, n_features, n_outputs = trainX.shape[0], trainX.shape[2], trainy.shape[1]
print('trainX.shape', trainX.shape) # (7000, 200, 5)
print('testX.shape', testX.shape) # (3000, 200, 5)
print('trainy.shape', trainy.shape) # (7000, 4)
print('testy.shape', testy.shape) # (3000, 4)
# reshape into subsequences (samples, time steps, rows, cols, channels)
n_features = trainX.shape[2]
n_steps, n_length = 4, 50
trainX = trainX.reshape((samples, n_steps, 1, n_length, n_features))
testX = testX.reshape((testX.shape[0], n_steps, 1, n_length,  n_features))

model = Sequential()
model.add(ConvLSTM2D(filters=64, kernel_size=(1,3),    activation='relu',return_sequences = True, input_shape=(n_steps, 1, n_length, n_features)))
model.add(MaxPooling1D(pool_size=3, strides=None, data_format='channels_last'))
model.add(BatchNormalization())

我遇到以下错误,

ValueError: Input 0 is incompatible with layer max_pooling1d_5: expected ndim=3, found ndim=5

0 个答案:

没有答案