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

貌似TextRNN_Att有问题! #8

Open
guotong1988 opened this issue Sep 25, 2019 · 21 comments
Open

貌似TextRNN_Att有问题! #8

guotong1988 opened this issue Sep 25, 2019 · 21 comments

Comments

@guotong1988
Copy link

@649453932
image

@649453932
Copy link
Owner

刚才试跑了一下,我这边是没问题的,你看下环境什么的有没有问题吧

@guotong1988
Copy link
Author

哦哦!

@guotong1988
Copy link
Author

guotong1988 commented Sep 25, 2019

我是python3.6,其他都一致
image

@649453932
Copy link
Owner

我跑了五次 出现了一次这种情况,loss成nan了,应该是代码里有bug,我明天找一下。感谢反馈!

@tfighting
Copy link

我pytorch1.2 python3.6 也有这个情况(nan),不知咋搞的,正在排查,不过还是感谢大佬这个文本分类系列,对于刚入门pytorch的小白真实一大福音啊,衷心谢谢!期待新作

@wangzhedaye
Copy link

我也是遇到同样状况了,和楼上一样,用的3.6和3.7都试过了,不知道哪有错误,求大佬帮助

@YangKing0834131
Copy link

请问loss成nan是否解决,谢谢

@wangzhedaye
Copy link

还没解决,您这边解决了吗

@hugen1996
Copy link

请问这个问题解决了吗?

@guotong1988
Copy link
Author

#19

@wangzhedaye
Copy link

我也没找到合适的解决方法

@guotong1988
Copy link
Author

我也没找到合适的解决方法

哥,看一下楼上的PR啊

@wangzhedaye
Copy link

我试过用虚拟环境一模一样,但还是有loss变成nan

@guotong1988
Copy link
Author

我试过用虚拟环境一模一样,但还是有loss变成nan

这么快?

@wangzhedaye
Copy link

当时各种都试过了,后来实在找不到原因

@guotong1988
Copy link
Author

我是说#19

@hugen1996
Copy link

@wangzhedaye
我今天又试了一下,应该是self.w = nn.Parameter(torch.Tensor(config.hidden_size * 2))这行代码有问题,
改成self.w = nn.Parameter(tensor.randn(config.hidden_size * 2)),我跑了多次没发现出现NaN的情况,
还有就是最后的fc层也有一点问题,
out = F.relu(out)
out = self.fc1(out)
out = self.fc(out) # [128, 64]
改成
out = F.relu(self.fc1(out))
out = self.fc(out) # [128, 64]

@wangzhedaye
Copy link

self.w = nn.Parameter(tensor.randn(config.hidden_size * 2))
NameError: name 'tensor' is not defined

@wangzhedaye
Copy link

self.w = nn.Parameter(torch.randn(config.hidden_size * 2))改成这个就好了啦,应该没问题了

@hugen1996
Copy link

@wangzhedaye 不好意思,打错了,把tensor改成torch就行了,你试一下,看是不是对的

@wangzhedaye
Copy link

我自己已经改好啦,哈哈哈,谢谢了

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

6 participants