I got the following RuntimeError for the matrix exponential: element 0 of tensors does not require grad and does not have a grad_fn. I don’t know how to make it work. Does anyone know where the problem is?
def test(x):
exp_x = torch.tensor(expm(x.detach().numpy()))
return torch.sum(exp_x)
x = torch.eye(3,3)
x = x.requires_grad_()
y = test(x)
y.backward()