You are on page 1of 2

PyTorch

Suppose one day you get an absolute brillient idea of project and you write down all details in a
single sheet of paper- the optimizer, the dataset and model architecture. and now you jTHust
have code it up and do hyperparameter tuning to put in to appliction. But no more , PyTorch
Lightning is here to save your day. Not only does it automatically do the hard work for you but it
also structures your code to make it more scalable. It comes fully packed with awesome
features that will enchance your machine learning experience. Beginners should definitely give a
go.

What is Pytorch

Based on the Torch library, PyTorch is an open-source machine learning library. Pytorch is
imperative, which means computations run immediately, and the user need not wait to write
the full code before checking if its works or not. We can efficiently run a part of the code and
inspect in real-time. The library is python based and built for providing flexibility as a deep
learning development program. PyTorch enables the support of dynamic computational graphs
that allows us to change the network on the fly.

Enter Lightning

Lightning is a very lightweight wrapper on PyTorch. This means you don't have to learn a new
library. It defers the core training and validation logic to you and automates the rest. It
guarantees tested and correct code with the best modem practices for the automated parts.

if(epoch==1000:

torch.save(net.state_dict(), "FinalModel.pth")

(how to save model in PyTorch)

#it comes with automatically with checkpoint saving

myTrainer=pl.Trainer(net.state_dict(), "FinalModel.pth")

In true sense, Lightning is a structuring tool for your PyTorch code. You just have to provide the
bare minimum details (Eg. number of epoch, optimizer, etc). The rest will be automated by
Lightning. It reduces the amount of work needed to be done. It ensures that you focus on the
real deal and not worry about how to run your model on multiple GPUs or speeding up the
code. Lightning will handle that for you.

You might also like