From the course: Computer Vision for Data Scientists

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

The training loop

The training loop

- [Instructor] Hi, I can't express how excited I am for you because learning about the training loop in PyTorch is a rite of passage, and I'm so honored to be here to guide you through this rite of passage. So, what is the training loop? Well, it involves several steps. It's the forward pass, the loss calculation, the backward pass, the parameter updates, and validation. So, let's just quickly walk through what we're doing with these first lines here. First thing we're doing is device configuration. We're going to check and see if a GPU is available using torch.cuda.is_available, right? If we do have a GPU available, we're going to assign it as cuda. If we don't, then we're going to set it to cpu, right? Then we are going to move the model to the device. We're going to move the model to the GPU. We're going to set the number of training epochs. For this example, we're just going to set the number of training epochs to two.…

Contents