我试图用keras训练LSTM模型,但我觉得我在这里弄错了.
我收到了错误
ValueError: Error when checking input: expected lstm_17_input to have
3 dimensions, but got array with shape (10000, 0, 20)
而我的代码看起来像
model = Sequential()
model.add(LSTM(256, activation="relu", dropout=0.25, recurrent_dropout=0.25, input_shape=(None, 20, 64)))
model.add(Dense(1, activation="sigmoid"))
model.compile(loss='binary_crossentropy',
optimizer='adam',
metrics=['accuracy'])
model.fit(X_train, y_train,
batch_size=batch_size,
epochs=10)
其中X_train的形状为(10000,20),前几个数据点类似
array([[ 0, 0, 0, ..., 40, 40, 9],
[ 0, 0, 0, ..., 33, 20, 51],
[ 0, 0, 0, ..., 54, 54, 50],
...
y_train的形状为(10000,),它是二进制(0/1)标签数组.
有人能指出我错在哪里吗?