我想在keras中创建有状态的LSTM。我使用了以下命令:
model.add(LSTM(300,input_dim=4,activation='tanh',stateful=True,batch_input_shape=(19,13,4),return_sequences=True))
批次大小为19。但运行时出现错误。
Exception: In a stateful network, you should only pass inputs with a number of samples that can be divided by the batch size. Found: 8816 samples. Batch size: 32.
我的脚本中没有指定批量大小为32,并且19可以被8816整除。
validation_data
,那么样本数量也必须能够被batch_size
整除。 - Renel Chesak