Computational Physics, Python, Linear Algebra, Svd, Code.
derivatives. x = Variable(torch.ones(2, 2), requires_grad=True) print(x) tensor([[1., 1.], [1., 1.]], requires_grad=True) print(x.data) tensor([[1., 1.], [1., 1.]]) print(x.grad) None y = x + 2 print(y) tensor([[3., 3.], [3., 3.]], grad_fn=<AddBackward0>) z = y * y * 3 out = z.sum() print(z, out)