关于y.grad报错
来源:3-32 Pytorch与autograd中的几个重要概念-autograd例子

qq_Theonlywinne_0
2022-08-25
UserWaring:The .grad attribute of a Tensor thatis not a leaf Tensor is being accessed.Its .grad attribute won’t be populated during autograd.backward().If you Indeed want the .grad field to be populated for a non-leaf Tensor,use .retain_grad() on the non-leaf Tensor.If you access the non-leaf Tensor by mistake ,make sure you access the leaf Tensor instead.See github.com/pytorch/pytorch/pull/30531 for more information
在print(y.grad)这一句报错,注释了就没错了
![![图片描述](http://img.mukewang.com/szimg/630765fe086d12ae17021276.jpg
写回答
1回答
-
会写代码的好厨师
2022-08-25
这个不是报错,是警告。可以不用管他。
00
相似问题