小编Yib*_*ang的帖子

运行时错误:叶变量已移至图形内部

我尝试使用 pytorch 进行自动渐变。当我测试时,我遇到了错误。我的代码如下:

w11 = torch.rand((100,2), requires_grad=True)
w12 = torch.rand((100,2), requires_grad=True)
w12[:,1] = w12[:,1] + 1
w13 = torch.rand((100,2), requires_grad=True)
w13[:,1] = w13[:,1] + 2
out1=(w11-w12)**2
out2=out1.mean()
out2.backward(retain_graph=True)
Run Code Online (Sandbox Code Playgroud)

pytorch

3
推荐指数
1
解决办法
2882
查看次数

标签 统计

pytorch ×1