1.LSTM报错:RuntimeError: Trying to backward through the graph a second time, but the saved intermediate results have already been freed. Specify retain_graph=True when calling backward the first time.
LSTM由于需要保存上一次的隐藏层信息,而backward之后这些信息会丢失,进而出现上述报错。解决方案可参考:https://blog.csdn.net/a845717607/article/details/104598278/
2.模型开始测试之前,需要model.eval(),防止测试过程中权重发生变化。