解决OSError: Error no file named pytorch

慈云数据 2024-03-13 技术支持 65 0

问题

解决OSError: Error no file named pytorch
(图片来源网络,侵删)

OSError: Error no file NAMEd pytorch_model.bin, tf_model.h5, model.ckpt.index or flax_model.msgpack found in directory

出现过程:

解决OSError: Error no file named pytorch
(图片来源网络,侵删)

使用transformers的Bertmodel时

问题代码

model = Bertmodel.from_pretrained('bert_model')

问题原因

下载的模型文件夹中没有pytorch_model.bin/tf_model.h5等文件,去原网址中查找也未发现相关文件。继而查看transformers官方使用说明:

from_pretrained(pretrained_model_name_or_path*model_args**kwargs)

  • pretrained_model_name_or_path – either: - a string with the shortcut name of a pre-trained model to load from cache or download, e.g.: bert-base-uncased. - a string with the identifier name of a pre-trained model that was user-uploaded to our S3, e.g.: dbmdz/bert-base-g

微信扫一扫加客服

微信扫一扫加客服

点击启动AI问答
Draggable Icon