m0_56731466 2022-08-09 18:58 采纳率: 0%
浏览 58
已结题

关于torch的问题

自己在修改网络结构的时候发现如下问题 但是在网上一直找也没有找到,求指点!!
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [7594, 64]] is at version 2; expected version 1 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
python-BaseException
使用torch.autograd.set_detect_anomaly(True)进一步寻找问题 发现了
[W ..\torch\csrc\autograd\python_anomaly_mode.cpp:104] Warning: Error detected in StackBackward. Traceback of forward call that caused the error:
但是一直没有找到解决办法

img

  • 写回答

2条回答 默认 最新

  • 我啥都会 2022-08-10 08:20
    关注

    问题大多是网络中的label和网络输出的维度大小不一样,也就是说,类别数为6类,而网络的输出为5类

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 8月10日
  • 赞助了问题酬金5元 8月9日
  • 创建了问题 8月9日