What’s the purpose of “retain_variables” in Variable backward function
How to use “retain_variables” in Variable backward function. I tried the following code:
zhengyun
Hi, <SCODE>import torch
from torch.autograd import Variable
x = Variable(torch.ones(2, 2), requires_grad = True)
y = x ** 2
y.backward(torch.ones(2, 2), retain_variables=False)
print "first backward of x is:"
print x.grad
y.backward(2*torch.ones(2, 2), retain_variables=False)
print "second backward of x is:"
print x.grad<ECODE>
albanD
I see. Thanks very much.
zhengyun