a = torch.Tensor(
[
[1,2],
[3,4]
]
)
print(a**2)`
from torch.autograd import Variable
a = Variable(torch.Tensor(
[
[1,2],
[3,4]
]
),requires_grad=True)
y = torch.sum(a**2) #y = 30
print(y)
y.backward() #gradient of y on a
print(a.grad)