|
|
|
|
|
by JarreNael
1500 days ago
|
|
In PyTorch: a = torch.tensor([2., 3.], requires_grad=True)
b = torch.tensor([6., 4.], requires_grad=True)
Q = 3*a**3 - b**2
external_grad = torch.tensor([1., 1.])
Q.backward(gradient=external_grad)
print(a.grad, b.grad) # the computed gradients.
All this is done on the GPU. Automatic Differentiation is the workhorse of modern NN. |
|