From the course: AI Workshop: Build a Neural Network with PyTorch Lightning
Unlock this course with a free trial
Join today to access over 24,200 courses taught by industry experts.
Training the model using the PyTorch Lightning Trainer - PyTorch Tutorial
From the course: AI Workshop: Build a Neural Network with PyTorch Lightning
Training the model using the PyTorch Lightning Trainer
We've defined our model, our training step, and validation step nicely encapsulated in a PyTorch Lightning module, and we are now ready to train our model. If you remember in PyTorch, you had to write a lot of code to actually train your model and get validation metrics for your model after each epoch. In addition, in order to ensure that your model trains on a GPU, if a GPU is present, you had to also move the model parameters as well as the X and Y values that you're using to train your model to the right device for training. Now, keep all of that in mind while we see how easy it is to train a model using PyTorch Lightning. You see those five lines of code here on screen, including the import statement, well, that's all the code you need to run a training loop, run validation at the end of every epoch, and display all of that nicely to screen. No nested for loops, no moving the model to the right device, no loss computation on training and validation data, no optimizer step, no…
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.