Hello everyone!
Work with part of the code below:
#data initialization
x = torch.randn(10, 10)
y = torch.randn(10, 1)
# param initialization
w = torch.randn(10, 1, requires_grad=True)
print('W before updating is leaf == ', w.is_leaf)
n_epoch = 1
for epoch in range(n_epoch):
loss = ((x @ w) ** 2).sum()
loss.backward()
w = w - w.grad * 0.01
print('W after updating is leaf == ', w.is_leaf)
Let’s, that I wanna do updating parameters without context manager torch.no_grad().
w = w - w.grad * 0.01
Does it cause to building new computational graph? Because this operation is using requires_grad=True variable?
Moreover, why w after updating become non-leaf variable?
I apologize in advance for the stupid question! Thank you!