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! 🙏

КОМЕНТАРІ • 59

  • @patloeber
    @patloeber  4 роки тому +28

    Let me know if you like this wrapper framework or not :)

    • @amirm7373
      @amirm7373 3 роки тому

      yeah it is quite good; But there is some subtle tricks which you have to know

    • @xspydazx
      @xspydazx 6 місяців тому

      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 !

  • @timmervyn6663
    @timmervyn6663 3 роки тому +14

    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!

    • @patloeber
      @patloeber  3 роки тому +2

      good to know, thanks!

    • @yookoT
      @yookoT Рік тому

      Thank you!

    • @hasesukkt
      @hasesukkt 9 місяців тому

      Thank you so much❤

  • @jack9025
    @jack9025 4 роки тому +8

    Been using Lightning for a couple months now. ITS AWESOME

  • @raymond-andrade
    @raymond-andrade Рік тому +2

    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.

  • @TechnGizmos
    @TechnGizmos 4 роки тому +5

    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.

    • @patloeber
      @patloeber  4 роки тому

      Glad that you enjoyed it! And thanks for the hint!

  • @thantyarzarhein5459
    @thantyarzarhein5459 4 роки тому +1

    Yesss and thanks, I have been waiting for it after u mentioned last video

  • @jinorohit2921
    @jinorohit2921 2 роки тому +1

    another fantastic video !

  • @arshadAlieusafzay
    @arshadAlieusafzay 4 роки тому +1

    As always, awesome tutorials. many thanks for your efforts

  • @mizumo1988
    @mizumo1988 Рік тому

    awesome tutorials. many thanks for your efforts

  • @pfever
    @pfever 2 роки тому

    Very nice tutorial, Thanks!

  • @TheAIEpiphany
    @TheAIEpiphany 3 роки тому +1

    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).

    • @patloeber
      @patloeber  3 роки тому

      It's open source so you can check out the contributor activity on GitHub. I don't think there is a perf overhead

  • @chakkarapaniv5487
    @chakkarapaniv5487 2 роки тому

    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.

  • @gigabytechanz9646
    @gigabytechanz9646 Рік тому

    Very interesting and useful!

  • @TotoGoTravel
    @TotoGoTravel 3 роки тому

    Thanx you for the perfect language that is not commonly spread along the python youtube channels. If you know what I mean)))))))

  • @jiahaozhang7571
    @jiahaozhang7571 4 роки тому +1

    Thank you so much. Extremely useful!

  • @monishkarunakaran5367
    @monishkarunakaran5367 4 роки тому

    Thanks for making our life's so easy

  • @shocamefromebay
    @shocamefromebay 4 роки тому +2

    This was a great video.

  • @mohd.faizan3003
    @mohd.faizan3003 4 роки тому

    I have really enjoyed your videos

  • @talhayousuf4599
    @talhayousuf4599 4 роки тому

    Pytorch Lightning is wonderful! But I could figure out How to use "pytorch lightning data module" for a custom (extremely large ) custom dataset?

  • @graceyudha
    @graceyudha Рік тому

    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

  • @user-wr4yl7tx3w
    @user-wr4yl7tx3w Рік тому

    does PyTorch Lightning work with Mac M2 chips?

  • @raminessalat9803
    @raminessalat9803 3 роки тому

    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?

  • @luelhagos631
    @luelhagos631 4 роки тому +1

    Awesome!

  • @user-or7ji5hv8y
    @user-or7ji5hv8y 4 роки тому +2

    Can you do a video on Lightning Bolt?

    • @patloeber
      @patloeber  4 роки тому

      Thanks for the tip! Frankly, I did not know about this library. But I will have a look into this

  • @anonim5052
    @anonim5052 7 місяців тому

    New import command due to update of lightning is "import lightning as pl"

  • @yuanjizhang9753
    @yuanjizhang9753 4 роки тому

    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)?

    • @patloeber
      @patloeber  4 роки тому

      model(X) and model.forward(X) should be the same here

    • @yuanjizhang9753
      @yuanjizhang9753 4 роки тому

      @@patloeber Thanks!

  • @mohd.faizan3003
    @mohd.faizan3003 4 роки тому

    Can you also make some for the transformers

  • @ИльяФедоров-м6б
    @ИльяФедоров-м6б 3 роки тому +1

    what is yours VS code theme?

  • @janmejaybhoi8065
    @janmejaybhoi8065 4 роки тому

    Hey there, is it necessary to be good at Pytorch so that I can learn Pytorch Lightening? I am a beginner in Pytorch.

    • @patloeber
      @patloeber  4 роки тому

      Yes I would recommend to start with "normal" PyTorch first

  • @robosergTV
    @robosergTV 2 роки тому

    was this a sponsored video? It sounds like an ad :)

  • @saurrav3801
    @saurrav3801 4 роки тому

    🔥

  • @ramisketcher2069
    @ramisketcher2069 4 роки тому

    Nice accent ♡

  • @chenkaihong
    @chenkaihong 4 роки тому

    first

  • @brandomiranda6703
    @brandomiranda6703 3 роки тому

    Who cares about tensorboard support when wandb/weights exists! ;)