AttributeError: ‘LSTM‘ object has no attribute ‘proj_size‘原因和解决办法

之前训练好的pytrorch模型现在重新打开就报错。报错为:

AttributeError: 'LSTM' object has no attribute 'proj_size'

开始我还以为是程序哪里错了,不科学啊,搜中文网站搜不到任何信息,用谷歌搜到了,链接如下:
https://github.com/flairNLP/flair/issues/2137
原因就是pytorch1.8版本的RNN系列函数都有问题,不能和之前的版本训练的模型兼容。到底有什么错,不清楚,1.8版本训练的模型能和1.7兼容吗?不清楚,也不打算试了。已经将torch降到1.7版本,错误消失了。运行正常。
清华镜像安装torch1.7.1如下:

pip uninstall torch
python3 -m pip install torch==1.7.1 torchvision -i https://pypi.tuna.tsinghua.edu.cn/simple

おすすめ

転載: blog.csdn.net/u011913417/article/details/118383685