Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytorch版本加载模型失败 #3

Open
yysirs opened this issue Oct 26, 2020 · 4 comments
Open

pytorch版本加载模型失败 #3

yysirs opened this issue Oct 26, 2020 · 4 comments

Comments

@yysirs
Copy link

yysirs commented Oct 26, 2020

代码:
model = BertForSequenceClassification.from_pretrained(model_name+"/bert_config.json") model.to(device)
报错:
OSError: Unable to load weights from pytorch checkpoint file. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

@houpanpan
Copy link
Collaborator

请将TF的版本改为1.4试一下,正常应该没有问题的

@houpanpan
Copy link
Collaborator

houpanpan commented Oct 27, 2020 via email

@yysirs
Copy link
Author

yysirs commented Oct 27, 2020 via email

@NotNingNing
Copy link

NotNingNing commented Nov 29, 2024

感谢问题解决了

------------------ 原始邮件 ------------------ 发件人: "valuesimplex/FinBERT" <[email protected]>; 发送时间: 2020年10月27日(星期二) 下午3:24 收件人: "valuesimplex/FinBERT"<[email protected]>; 抄送: "刘曙"<[email protected]>;"Author"<[email protected]>; 主题: Re: [valuesimplex/FinBERT] pytorch版本加载模型失败 (#3) 您好! 您这个报错应该是版本的问题,将tensorflow的版本改为1.14试试呢,我们这边都是没有问题的。

---------- Origin message ---------- >From:"桐原因" <[email protected]> >To:"valuesimplex/FinBERT" <[email protected]> >Subject:[valuesimplex/FinBERT]pytorch版本加载模型失败(#3) >Date:2020-10-26 16:46:25 代码: model = BertForSequenceClassification.from_pretrained(model_name+"/bert_config.json") model.to(device) 报错: OSError: Unable to load weights from pytorch checkpoint file. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

老哥,我不太会怎么将该预训练模型进行情感分析,您能够教教我吗?万分感谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants