• RuntimeError: Function 'AddmmBackward' returned nan values in its 2th output.


    1.训练报错

    使用BCE损失时,出现的问题包括:

    报错  参数batch_size |   epoch |   hidden_size |   lr_D |   lr_DZ |   lr_Eref |   lr_model |   z_dim
    'ViewBackward' returned nan values   8 |      50 |           128 | 5e-05  |  0.001  |    0.001  |     0.001  |      16
    MvBackward 16 |      40 |           256 | 0.01   |  0.001  |    0.001  |     5e-05  |      16
    AddmmBackward 32 |      40 |           256 | 0.01   |  5e-05  |    5e-05  |     5e-05  |     128
    ViewBackward 32 |      75 |           128 | 5e-05  |  0.01   |    0.001  |     0.0001 |      64
    ViewBackward 8 |      25 |            64 | 0.001  |  5e-05  |    0.01   |     0.0001 |      32

    但是这里也观察不出来什么规律。

    但是这是少量出现的,在50个模型中,只有6个是出现Nan值。是否可以忽略这个问题呢?

    2.解决办法

    https://github.com/pytorch/pytorch/issues/51196,这里提到说

    This error is only here in anomaly mode to help you find where nans appeared in the backward pass. This is not related to a bug in PyTorch but just that your current code generate nan values.
    You can remove this error by just disabling anomaly detection.

    注释掉:

    torch.autograd.set_detect_anomaly(True)

    但是也不是根本解决办法吧?

  • 相关阅读:
    XML时代离我们有多远?
    关注程序员健康之——最佳答案梅核气
    巾帼不让须眉 IT界10大女性CEO排行
    网站?XML?我的思考
    企业建站代码HTML滚动文字代码(垂直)
    web前端工程师:WEB标准,Web前端开发工程师必备技术列表
    数据库开发
    面向.NET 的XML 程序设计
    脾与胃病辨证
    技术部工作中常见问题(o_company)
  • 原文地址:https://www.cnblogs.com/BlueBlueSea/p/15541550.html
Copyright © 2020-2023  润新知