当前位置: 代码迷 >> 综合 >> PyTorch】RuntimeError: one of the variables needed for gradient computation has been modified by an
  详细解决方案

PyTorch】RuntimeError: one of the variables needed for gradient computation has been modified by an

热度:101   发布时间:2023-11-21 13:18:26.0

解决

forward()函数里面不要用:

tensor1 += 1

这样的操作

改成:

tensor1 = tensor1 + 1

都ok!

  相关解决方案