Automatic Gradients with PyTorch
Let’s see how we can compute automatic gradients with PyTorch and how PyTorch is different from plain Python and NumPy.
Creating a tensor with requires_grad=True
argument
The following code creates a tensor called x
just like before, but this time we give PyTorch
an additional option requires_grad=True
. We’ll see very soon what this option does.
Run the code to see what printing x
does.
Get hands-on with 1400+ tech skills courses.