当前位置:   article > 正文

[已解决]OSError: Unable to load weights from pytorch checkpoint file

[已解决]OSError: Unable to load weights from pytorch checkpoint file

问题说明:

最近跑代码遇到了一个奇怪的问题:

OSError: Unable to load weights from pytorch checkpoint file for '/root/.cache/huggingface/transformers/c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7' at '/root/.cache/huggingface/transformers/c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

OSError: Unable to load weights from pytorch checkpoint file for '/root/.cache/huggingface/transformers/c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7' at '/root/.cache/huggingface/transformers/c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

报错最后一句是“If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

我要加载的模型文件并不是Tensorflow格式的,就算在加载模型的那一行代码里面添加参数from_tf=True还是会报错

解决方法:

进入以下目录:(不同用户的路径可能不太一样)

/root/.cache/huggingface/transformers

找到报错的那个文件,我这里是:“c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7”

这个文件下面分别有以.json和.lock结尾的文件,一共三个文件全部删了

再次运行代码会从huggingface上重新下载相关文件,然后就不会报错了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/391963?site
推荐阅读
相关标签
  

闽ICP备14008679号