We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http://www.datakit.cn/blog/2017/03/03/pytorch_01_basic.html
The text was updated successfully, but these errors were encountered:
请问,为什么运行第3部分的代码
x = Variable(torch.ones(1), requires_grad = True) y = x ** 2 + 3 y.backward(retain_variables=True) print(x.grad) # 梯度值是 2*x = 2
target = torch.FloatTensor([10]) y.backward(target, retain_variables=True) print(x.grad) # 梯度值是 2*x = 20, 因为retain的设置为true, grad会加上原来的梯度值2, 结果是22
会报错 TypeError: backward() got an unexpected keyword argument 'retain_variables'
Sorry, something went wrong.
No branches or pull requests
http://www.datakit.cn/blog/2017/03/03/pytorch_01_basic.html
The text was updated successfully, but these errors were encountered: