-
Notifications
You must be signed in to change notification settings - Fork 699
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
自己训练的情感分析模型在Inference代码里面加载报错 #15
Comments
您好,请问您的问题解决了吗?我这边用训练好的sentiment_model_epoch.418这个模型都会报key(s) in state_dict: "dense.weight", "dense.bias"这个错误,设置false的话基本都在0.3-0.4,我也不知道咋整了 |
你们可以看看 很明显就是因为你们训练的模型参数里面多了dense.weight", "dense.bias”模型参数,那是因为训练时候的模型和预测模型里面用的不一样,你们可以仔细看看导入的模型 |
我还没有训练啊 我就是用的博主提供的训练好的模型,去做测试的时候就报这个错误了 |
请问该怎么解决呢 |
解决了,在进行情感训练和分析的时候,引入的文件应该同时为 bert_sentiment_analysis 或者bert_sentiment_analysis_v2,博主给的训练好的应该是用的第一个,但是代码里的训练代码用的是v2这个。 |
您好,看了您bert视频受益匪浅。有个问题想请教一下您,用您训练好的sentiment_model_epoch.418这个模型执行Sentiment_Inference.py时候是正常的,而我自己训练出来的模型放进去执行时候出现Unexpected key(s) in state_dict: "dense.weight", "dense.bias"。load_state_dict()里面strict设为False的话可以正常执行,但是出来的正负样本预测值都在0.25左右明显不对。我去检查了下训练时候all_label和all_prediction都是很正常的,所以现在不知道该怎么解决这个问题。
The text was updated successfully, but these errors were encountered: