x=torch.rand(2,2,requires_grad=True)
y=x+2
# y=x*2
z=torch.sum(y)
zz=z*2
z.backward()
zz.backward()
call backward() twice does not incur errors. However, if i use y=x*2
rather than y=x+2
, the error occurs, why?
x=torch.rand(2,2,requires_grad=True)
#y=x+2
y=x*2
z=torch.sum(y)
zz=z*2
z.backward()
zz.backward()