Hi there,
I have run these pieces of code, but the results are strange:
x = torch.zeros(10, 300, requires_grad=True)
loss = torch.max(x)
loss.backward(retain_graph=True)
x.grad

Here, x.grad is correct.
Another script.
x = torch.zeros(10, 300, requires_grad=True).to(device)
loss = torch.max(x)
loss.backward(retain_graph=True)
x.grad

x.grad becomes None.
Why? Thanks!