10 Adopting PyTorch Lightning
This chapter covers:
- Implementing PyTorch Lightning to reduce boilerplate code
- Adding training, validation, and test support for the DC taxi model
- Analyzing DC taxi model training and validation using Pandas
Until this chapter in the book, you wrote your own implementation of the methods that included the specific steps related to training and testing of your machine learning model. However, much of the code you wrote was unrelated to your machine learning model architecture and could have applied to a broad range of distinct models. Building on this observation, this chapter introduces you to PyTorch Lightning, a framework that can help you reduce the quantity of boilerplate, engineering code in your machine learning system, and consequently help you focus on evolving your model design and implementation.
This section introduces the PyTorch Lightning framework for your PyTorch DC taxi fare estimation model and teaches you the steps involved in enabling PyTorch Lightning training, validation, and test features.
Until this point in the book, you had to implement a sizable portion of Python and PyTorch boilerplate code for your machine learning model. This meant that only a few parts of your implementation were model specific such as the code to:
- package the feature values as tensors
- configure the neural net layers
- calculate the tensors for the loss
- report on the model metrics