首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >RuntimeError:在就地操作中使用要求梯度的叶变量的视图。

RuntimeError:在就地操作中使用要求梯度的叶变量的视图。
EN

Stack Overflow用户
提问于 2021-08-28 09:18:11
回答 1查看 607关注 0票数 0

我得到了这个错误在一个代码中实现的PyTORTOR0.3。我正在尝试运行代码,但是我得到了这个错误。

代码语言:javascript
运行
复制
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:4044: UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.
"Default grid_sample and affine_grid behavior has changed "
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at /pytorch/c10/core/TensorImpl.h:1156.)
return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
Traceback (most recent call last):
File "eval_pf_pascal.py", line 73, in
corr4d = model(batch)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/content/ncnet/lib/model.py", line 275, in forward
corr4d = self.NeighConsensus(corr4d)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/content/ncnet/lib/model.py", line 147, in forward
x = self.conv(x)+self.conv(x.permute(0,1,4,5,2,3)).permute(0,1,4,5,2,3)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/container.py", line 139, in forward
input = module(input)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/content/ncnet/lib/conv4d.py", line 126, in forward
use_half=self.use_half,
File "/content/ncnet/lib/conv4d.py", line 52, in conv4d
padding=padding,
RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation.

关于如何解决这个问题的任何想法。

EN

回答 1

Stack Overflow用户

发布于 2022-10-13 03:55:46

如果您正在执行像tensor1 += tensor2这样的操作

试试tensor1.data += tensor2

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68962973

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档