我正在尝试在GTZAN数据集上实现 CNN + LSTM 架构。我将在下面解释我的训练和验证集:
X_train.shape #(10000, 64, 173, 1)
Y_train.shape #(10000, 10, 1)
X_valid.shape #(2000, 64, 173, 1)
Y_valid.shape #(2000, 10)
我的模型如下:
input_shape = (10000, 64, 173, 1)
model = Sequential()
model.add(TimeDistributed(Conv2D(24, 5, 5, activation='relu', subsample=(5, 4),
border_mode='valid'), input_shape=input_shape))
model.add(TimeDistributed(MaxPooling2D(pool_size = (2,2))))
model.add(TimeDistributed(Flatten()))
model.add(LSTM(64, return_sequences=True))
model.add(Dense(output_dim=1, activation = "softmax"))
model.summary()
模型编译:
from keras.optimizers import Adam
model.compile(optimizer=Adam(lr = 1e-5), loss="categorical_crossentropy", metrics=['accuracy'])
模型适合:
from keras.callbacks import EarlyStopping
early_stopping = EarlyStopping(monitor='val_loss', patience=20, verbose=2)
history = model.fit(X_train, Y_train, epochs=90, batch_size=32, validation_data= (X_valid, Y_valid), callbacks=[early_stopping])
但我得到一个错误说,
ValueError:检查输入时出错:预期 time_distributed_126_input 有 5 个维度,但得到了一个形状为 (10000, 64, 173, 1) 的数组
我究竟做错了什么?我是新来的