From the course: Up and Running with PyTorch by Pearson

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Effortless backpropagation with torch.autograd

Effortless backpropagation with torch.autograd - PyTorch Tutorial

From the course: Up and Running with PyTorch by Pearson

Effortless backpropagation with torch.autograd

I want to give you a concrete example and show you why Torch's automatic differentiation library makes not only deep learning possible with these incredibly large neural networks, but easy and fun in a way. So to start, this is going to be a stripped-down automatic differentiation example based on the function we just saw. So here, we can use Torch and use its ARange function again to create a tensor, in this case with values between 0 and 1. A new thing with ARange here is we can actually specify what step we want. So instead of evenly spaced steps of 1, like we saw when we were working with tensors, we can specify the step we want. And it will figure out how many actual data points to make to correctly take the steps from the beginning of 0 to the end of 1 here. And another new thing that we didn't see just working with tensors, kind of raw tensors, if you will, is that in PyTorch, you might see requires grad if you're looking at other model or neural network code at various points…

Contents