KaihuaTang / Long-Tailed-Recognition.pytorch

[NeurIPS 2020] This project provides a strong single-stage baseline for Long-Tailed Classification, Detection, and Instance Segmentation (LVIS). It is also a PyTorch implementation of the NeurIPS 2020 paper 'Long-Tailed Classification by Keeping the Good and Removing the Bad Momentum Causal Effect'.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于训练过程中loss突然变成nan,acc变成0的问题

isunLt opened this issue · comments

您好,感谢您分享的代码,我在训练模型的过程中出现了loss突然变成nan,acc变成0的问题,我分别从头开始进行了两次训练,但是还是产生了一样的问题。
我的训练环境是:

  • Nvidia RTX 2080Ti cuda10.1+cudnn7.6.3
  • python3.8.5+pytorch1.5.1
  • 数据集是ILSVRC2015
  • 由于显存只有11G,所以我在config里把batch_size改成了64
  • 其他不变

请问您知道可能的原因是什么吗?您用的ImageNet-LT是由ILSVRC2015提取的吗?
loss2nan

loss2nan2

不好意思打扰了,我把python换成3.7,pytorch换成1.6之后就没问题了。

抱歉我又来了,在换成python3.7、pytorch1.6以后,到训练的最后还是出现了老问题。
微信截图_20201026093554

不好意思没有遇到过类似问题,我也不知道为什么

可能是因为改了batch size,learning rate也需要对应的修改?

还有种可能是要在所有normalize的分母处加一个 1e-9 或者 1e-12。因为不知道什么原因分母的norm值训练的太小了,但是我自己没遇到类似问题。

image

还有种可能是要在所有normalize的分母处加一个 1e-9 或者 1e-12。因为不知道什么原因分母的norm值训练的太小了,但是我自己没遇到类似问题。

image

谢谢您,我去试一下。

请问您问题解决了吗?我改了norm还是会出现nan,我的loss下降很快,在一个epoch内就变nan了

请问您问题解决了吗?我改了norm还是会出现nan,我的loss下降很快,在一个epoch内就变nan了

太久了,我忘记了,不好意思

commented

还有种可能是要在所有normalize的分母处加一个 1e-9 或者 1e-12。因为不知道什么原因分母的norm值训练的太小了,但是我自己没遇到类似问题。

image

I had the same problem and I fixed it by following Tang's advice. That's really helpful, thx.