目录
nan判断方法:
if torch.any(torch.isnan(a)):
也可以参考我的另一篇博客:
pytorch nan问题_python torch isnan any-优快云博客
卷积后,值为-inf,在后面的bn层中出现nan。
可以加个x=torch.clip(x,-1e5,1e5)
如果float16的话,会越界,可以改为:
可以加个x=torch.clip(x,-1e4,1e4)
目录
if torch.any(torch.isnan(a)):
也可以参考我的另一篇博客:
pytorch nan问题_python torch isnan any-优快云博客
可以加个x=torch.clip(x,-1e5,1e5)
如果float16的话,会越界,可以改为:
可以加个x=torch.clip(x,-1e4,1e4)