使用LSTM层时应如何设置输出层?

时间:2019-12-11 03:36:53

标签: machine-learning keras deep-learning

时间步长= 100 功能= 4

我希望时间步长为100,特征数量为4,模型的最后一层为1。但是尝试,但是出错。我们应该如何解决这个问题?是否应添加LSTM层?

model = Sequential()
model.add(LSTM(64, input_shape = (100, 4)))
model.add(Dense(32))
model.add(Dense(16))
model.add(Dense(8))
model.add(Dense(4))
model.add(Dense(1))


model.compile(optimizer=Adam(lr = 0.01), loss = 'mean_squared_error',metrics=['acc'])

model.fit(X_train, Y_train, epochs = 300, batch_size=100, verbose = 1, shuffle=True, callbacks=[early_stopping_callback, checkpointer], 
      validation_data=(X_test,Y_test))

这是错误...

ValueError: Error when checking target: expected dense_56 to have shape (1,) but got array with shape (4,)

0 个答案:

没有答案