【发布时间】:2026-01-03 17:05:02
【问题描述】:
我想在 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 整除
【问题讨论】: