From the course: Hands-On PyTorch Machine Learning
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Advanced PyTorch autograd
From the course: Hands-On PyTorch Machine Learning
Advanced PyTorch autograd
- [Instructor] There's a lot more to AutoGrad and PyTorch. Let's try something more complex. In this first example, we first generate three random numbers, assign them to a variable called X, and we require, in this case, gradients for X. We then provide some operations on X to generate a new variable called Y, which will have a gradient function attached to it. Now, let's print out the gradient for X. So in your Neural Network, parameters that don't compute gradients are usually called frozen parameters. It is useful to freeze part of your model if you know in advance that you won't need the gradients of those parameters. This offers some performance benefits by reducing AutoGrad computations. Let's walk through a small example to demonstrate this. We'll first import some libraries, including torchvision, in this case. We load a pre-trained resnet18 model, in this case, and then freeze all of the parameters. Assume…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.