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中运行train.py的问题 #32

Open
zzy-java opened this issue Oct 20, 2019 · 6 comments
Open

pytorch中运行train.py的问题 #32

zzy-java opened this issue Oct 20, 2019 · 6 comments

Comments

@zzy-java
Copy link

QQ图片20191020153613
这是我运行过程出现的问题,不懂是出错的原因

@zzy-java
Copy link
Author

希望有大佬能帮帮忙

@yukangyin97
Copy link

我也遇到了你这个问题,问题产生的原因是calculate()函数中的一句话“entity = [id2word[x[j]] + '/' + id2tag[y[j]]]”,其中id2word[x[j]]中的x必须是list类型才正确,但是因为程序在进入calculate()函数之前,给x传的值是tensor类型的,所以会出现这个错误。解决问题的办法就是在调用calcualte()函数之前,先把x从tensor类型转换为list类型,再调用calculate()函数.

@zzy-java
Copy link
Author

非常感谢。我之前查了好久产生问题的原因,后面是使用和你一样的方法解决的。

@Resbonsiblyat
Copy link

可以x.numpy()[j]替换x[j]解决

@azhe1234
Copy link

可以x.numpy()[j]替换x[j]解决

image
我这样做,又报了这个错误

@azhe1234
Copy link

我也遇到了你这个问题,问题产生的原因是calculate()函数中的一句话“entity = [id2word[x[j]] + '/' + id2tag[y[j]]]”,其中id2word[x[j]]中的x必须是list类型才正确,但是因为程序在进入calculate()函数之前,给x传的值是tensor类型的,所以会出现这个错误。解决问题的办法就是在调用calcualte()函数之前,先把x从tensor类型转换为list类型,再调用calculate()函数.

请问为啥我改完报这个错误啊
image

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

4 participants