PyTorch Lightning Tutorial - Lightweight PyTorch Wrapper For ML Researchers
Вставка
- Опубліковано 22 лис 2024
- PyTorch Lightning is a lightweight PyTorch wrapper that helps you scale your models and write less boilerplate code. In this Tutorial we learn about this framework and how we can convert our PyTorch code to a Lightning code.
Lightning is nothing more than organized PyTorch code, so once you’ve organized it into a LightningModule, it automates most of the training for you.The beauty of Lightning is that it handles the details of when to validate, when to call .eval(), turning off gradients, detaching graphs, making sure you don’t enable shuffle for val, etc…
~~~~~~~~~~~~~~ GREAT PLUGINS FOR YOUR CODE EDITOR ~~~~~~~~~~~~~~
✅ Write cleaner code with Sourcery: sourcery.ai/?u... *
🚀🚀 JOIN MY NEWSLETTER 🚀🚀
www.python-eng...
🚀🚀 Get exclusive content on Patreon: 🚀🚀
/ patrickloeber
If you enjoyed this video, please subscribe to the channel!
Code:
github.com/pat...
PyTorch Lightning:
github.com/PyT...
pytorch-lightn...
My PyTorch Course:
• PyTorch Tutorials - Co...
github.com/pat...
Tensorboard Tutorial:
• PyTorch Tutorial 16 - ...
You can find me here:
Website: www.python-eng...
Twitter: / patloeber
GitHub: github.com/pat...
#Python #PyTorch
----------------------------------------------------------------------------------------------------------
This is a sponsored link. By clicking on it you will not have any additional costs, instead you will support me and my project. Thank you so much for the support! 🙏
Let me know if you like this wrapper framework or not :)
yeah it is quite good; But there is some subtle tricks which you have to know
yes but how to open the app local .. as to get aproved for the online studio is a nightmare and its been months !
so local is the best method !
Many thanks for your work on this series. It is much appreciated. One point to make about this tutorial is that the code for interfacing PyTorch Lightning with TensorBoard has changed.
Now Lightning uses Loggers and fortunately TensorBoard is its default logger.
To get your code to work on the latest TensorBoard replace, or comment out, these two lines in the training_step function:
# tensorboard_logs = {'train_loss': loss.detach()} and
# return {'loss': loss, 'log': tensorboard_logs} with the simpler
self.log("train_loss", loss ) # and then just
return loss
Make similar changes in the validation_epoch_end function usin:
self.log("val_loss": avg_loss)
return avg_loss
to replace the original two lines which used a dictionary format as shown above.
Thanks again for your wonderful work. I hope to soon see a PyTorch tutorial on
autoencoders!
good to know, thanks!
Thank you!
Thank you so much❤
Been using Lightning for a couple months now. ITS AWESOME
Nice!
Very well explained. As someone who just recently got used to PyTorch, it's nice to see Lightning allows me to skip a lot of the manual looping and optimizer/loss management. Thanks for also including the snippet about the Tensorboard, which is also very helpful instead of generating your own graphs in Matplotlib.
Finally done with your Pytorch playlist!! Your videos have gradually removed my fears about implementing neural networks and will now serve as the foundations upon which I will grow my knowledge base in AI. I recommended this series to my brother who is an ML research scientist and he's also learning a lot from it. Thank you very much for this and I hope your channel grows by leaps and bounds as the field grows.
BTW there's an update w.r.t. returning the dictionary in the validation_epoch_end() function:
UserWarning: The validation_epoch_end should not return anything as of 9.1.to log, use self.log(...) or self.write(...) directly in the LightningModule warnings.warn(*args, **kwargs)
UserWarning: The {log:dict keyword} was deprecated in 0.9.1 and will be removed in 1.0.0
Please use self.log(...) inside the lightningModule instead.
Glad that you enjoyed it! And thanks for the hint!
Yesss and thanks, I have been waiting for it after u mentioned last video
another fantastic video !
As always, awesome tutorials. many thanks for your efforts
Thanks!
awesome tutorials. many thanks for your efforts
Very nice tutorial, Thanks!
Love the idea behind it! Abstract the engineering from science.
I wonder what happens when something doesn't work though - how painful is it to debug it? How responsive are the contributors when there is a bug?
Also, I'd love to know the perf overhead, etc. (I guess it can't be too big and the framework is probably geared towards rapid prototyping and not production either way)
All of those would have to have a satisfying answer for me to wish to switch to PyTorch Lightning (PyTorch user here).
It's open source so you can check out the contributor activity on GitHub. I don't think there is a perf overhead
Hi, Thanks for the tutorial. I would like to know how to do the predictions logic for the trained model. Could you please share some information on it.
Very interesting and useful!
Thanx you for the perfect language that is not commonly spread along the python youtube channels. If you know what I mean)))))))
Thank you so much. Extremely useful!
Glad you like it !
Thanks for making our life's so easy
Glad it is helpful!
This was a great video.
Thank you!
I have really enjoyed your videos
Glad to hear that!
Pytorch Lightning is wonderful! But I could figure out How to use "pytorch lightning data module" for a custom (extremely large ) custom dataset?
is this basically keras but for pytorch? i usually make deep learning model using Tensorflow and recently picked up to learn Pytorch. as frustating as it is. i manage to make a non-mnist model. but it seem a lot more complicated than tensorflow
does PyTorch Lightning work with Mac M2 chips?
Thanks a lot! Have a question: when you used 'model' instead of 'self' (the mistake you mentioned on the video), what does code exactly do? what is it understanding as 'model' in that method?
Awesome!
thanks!
Can you do a video on Lightning Bolt?
Thanks for the tip! Frankly, I did not know about this library. But I will have a look into this
New import command due to update of lightning is "import lightning as pl"
Excellent tutorial! Thank you so much! I have a question in github code file lines 41 & 76: outputs = self(images). Should it be outputs = self.forward(images)?
model(X) and model.forward(X) should be the same here
@@patloeber Thanks!
Can you also make some for the transformers
what is yours VS code theme?
Night Owl
Hey there, is it necessary to be good at Pytorch so that I can learn Pytorch Lightening? I am a beginner in Pytorch.
Yes I would recommend to start with "normal" PyTorch first
was this a sponsored video? It sounds like an ad :)
🔥
Nice accent ♡
haha thanks: It's German ;)
@@patloeber Schöner ..♡♡
first
Who cares about tensorboard support when wandb/weights exists! ;)