649453932 / Chinese-Text-Classification-Pytorch

中文文本分类,TextCNN,TextRNN,FastText,TextRCNN,BiLSTM_Attention,DPCNN,Transformer,基于pytorch,开箱即用。
MIT License
5.38k stars 1.24k forks source link

貌似TextRNN_Att有问题! #8

Open guotong1988 opened 5 years ago

guotong1988 commented 5 years ago

@649453932 image

649453932 commented 5 years ago

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

guotong1988 commented 5 years ago

哦哦!

guotong1988 commented 5 years ago

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

649453932 commented 5 years ago

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

tfighting commented 5 years ago

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

wangzhedaye commented 5 years ago

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

YangKing0834131 commented 5 years ago

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

wangzhedaye commented 5 years ago

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

hugen1996 commented 5 years ago

请问这个问题解决了吗?

guotong1988 commented 5 years ago

https://github.com/649453932/Chinese-Text-Classification-Pytorch/pull/19

wangzhedaye commented 5 years ago

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

guotong1988 commented 5 years ago

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

哥,看一下楼上的PR啊

wangzhedaye commented 5 years ago

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

guotong1988 commented 5 years ago

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

这么快?

wangzhedaye commented 5 years ago

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

guotong1988 commented 5 years ago

我是说https://github.com/649453932/Chinese-Text-Classification-Pytorch/pull/19

hugen1996 commented 5 years ago

@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 commented 5 years ago

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

wangzhedaye commented 5 years ago

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

hugen1996 commented 5 years ago

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

wangzhedaye commented 5 years ago

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