Autoencoder In PyTorch - Theory & Implementation

2024 ж. 10 Мам.
63 067 Рет қаралды

In this Deep Learning Tutorial we learn how Autoencoders work and how we can implement them in PyTorch.
Get my Free NumPy Handbook:
www.python-engineer.com/numpy...
✅ Write cleaner code with Sourcery, instant refactoring suggestions in VS Code & PyCharm: sourcery.ai/?... *
⭐ Join Our Discord : / discord
📓 ML Notebooks available on Patreon:
/ patrickloeber
If you enjoyed this video, please subscribe to the channel:
▶️ : / @patloeber
Resources:
www.cs.toronto.edu/~lczhang/3...
Code: github.com/patrickloeber/pyto...
More PyTorch Tutorials:
Complete Beginner Course: • Deep Learning With PyT...
Dataloader: PXOzkkB5eH0
Transforms: • PyTorch Tutorial 10 - ...
Model Class: • PyTorch Tutorial 06 - ...
CNN: • PyTorch Tutorial 14 - ...
~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~
🖥️ Website: www.python-engineer.com
🐦 Twitter - / patloeber
✉️ Newsletter - www.python-engineer.com/newsl...
📸 Instagram - / patloeber
🦾 Discord: / discord
▶️ Subscribe: / @patloeber
~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~
🅿 Patreon - / patrickloeber
#Python PyTorch
Timeline:
00:00 - Theory
02:58 - Data Loading
05:30 - Simple Autoencoder
15:02 - Training Loop
17:00 - Plot Images
19:00 - CNN Autoencoder
29:12 - Exercise For You
----------------------------------------------------------------------------------------------------------
* This is an affiliate 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 enjoyed the new animations in the beginning and want to see this more in the future :)

    @patloeber@patloeber3 жыл бұрын
    • Hi Patrick, Any plans to have a series on NLP state of the art models?

      @sumithhh9379@sumithhh93793 жыл бұрын
    • They're great

      @MrDeyzel@MrDeyzel3 жыл бұрын
    • Love the animations and want more. Learning pytorch and following your tutorials.

      @md.musfiqurrahaman8612@md.musfiqurrahaman86122 жыл бұрын
  • big thanks to you. i cannot imagine how could i learn my dl course without your tutorial. Your work is the best in youtube so far!

    @jh-pq9tp@jh-pq9tp2 жыл бұрын
  • I love all your PyTorch videos, please do more :D

    @starlite5097@starlite50973 жыл бұрын
    • Thanks! I will :)

      @patloeber@patloeber3 жыл бұрын
  • Nice, was waiting for this :)

    @salimibrahim459@salimibrahim4593 жыл бұрын
    • Hope you enjoyed it!

      @patloeber@patloeber3 жыл бұрын
  • Great work!

    @pleasedontsubscribeme4397@pleasedontsubscribeme43973 жыл бұрын
  • Thank you so much for clear presentation of Autoencoder!

    @saeeddamadi3823@saeeddamadi38232 жыл бұрын
    • glad you like it!

      @patloeber@patloeber2 жыл бұрын
  • Great video! Could you provide the same walkthrough for a variational autoencoder? Or point point me to a good walkthrough on the theory and implementation of a variational autoencoder?

    @huoguo7426@huoguo74262 жыл бұрын
  • Its reaallly nice but it would be a very nice addition to include variational autoencoders and Generative adversial networks as well :). Maybe they can be helpful to many struggling with class imbalance during classification

    @saadmunir1467@saadmunir14673 жыл бұрын
    • Great suggestion!

      @patloeber@patloeber3 жыл бұрын
  • Thank you for your nice tutorials please do the same for a non-image data. I'm curious to see CNN auto-encoders with non-image data.

    @shahinghasemi2346@shahinghasemi23463 жыл бұрын
  • Hey Patrick a really informative and concise video! Thoroughly enjoyed it :DD Just a small correction at 12:51, you used the word dimension while explaining the Normalize transform, whereas the two attributes are just the mean and standard deviation of the resultant normalized data.

    @adityasaini491@adityasaini4912 жыл бұрын
    • thanks for the hint!

      @patloeber@patloeber2 жыл бұрын
  • Very clear, thank you very much

    @markavilin5020@markavilin50202 жыл бұрын
  • hello, nice videos you have. looking forward new videos on paper review and implementations.

    @garikhakobyan3013@garikhakobyan30133 жыл бұрын
  • at 22:17 when calculating the shape of the conv output, it should be 128*128*1 => 64*64 * 16 and the rest should also be different accordingly

    @ayankashyap5379@ayankashyap53792 жыл бұрын
  • Great work!! Thanks :))

    @harshkumaragarwal8326@harshkumaragarwal83263 жыл бұрын
  • TopNotch explanation! Thx.

    @Jerrel.A@Jerrel.A Жыл бұрын
  • Very cool. Thank you.

    @satpalsinghrathore2665@satpalsinghrathore2665 Жыл бұрын
  • Nice explanation

    @anarkaliprabhakar6640@anarkaliprabhakar66404 ай бұрын
  • Yet another Pytorch video🔥

    @CodeWithTomi@CodeWithTomi3 жыл бұрын
    • Can u help to implement pytorch with django

      @devadharshan6328@devadharshan63283 жыл бұрын
    • man you are fast :D

      @patloeber@patloeber3 жыл бұрын
    • Can u upload Ur GUI chat bot code in GitHub I tried code along approach I was able to learn the concept but I got some few bugs . Can u upload it

      @devadharshan6328@devadharshan63283 жыл бұрын
    • I added the code here: github.com/python-engineer/python-fun

      @patloeber@patloeber3 жыл бұрын
    • @@patloeber thanks

      @devadharshan6328@devadharshan63283 жыл бұрын
  • Great animations my suggestion is to add in more animations not only in theory but also in the working of the code . Just my suggestion but great video thanks for Ur teaching.

    @devadharshan6328@devadharshan63283 жыл бұрын
    • thanks! definitely a good idea

      @patloeber@patloeber3 жыл бұрын
  • Thank you so much , you explained it really good.

    @ingenuity8886@ingenuity88865 күн бұрын
  • This channel is really good, I learned PyTorch from this channel. Guys I assure you subscribe to this channel.

    @Mesenqe@Mesenqe3 жыл бұрын
    • Thanks so much:) appreciate the nice words

      @patloeber@patloeber3 жыл бұрын
  • Hey Patrick I used your exact code to train the CNN based autoencoder but couldn't get it to converge without Batch Normalization, after adding BatchNorm2d after every ReLU it works fine, but without it, it doesn't, tried different values for lr from 1e-2 to 1e-5. I was training on MNIST dataset only. the loss becomes NaN or ranges between 0.10 to 0.09.

    @ujjwalkumar-uf8nj@ujjwalkumar-uf8nj10 ай бұрын
  • is it possible to use sentences as input data?

    @lankanathaekanayake7680@lankanathaekanayake76802 жыл бұрын
  • you used recons and img as input for loss function, however if we want to train my model and test it we should use "recon" and "labels" as an input for loss function. but the labels are 3D, how we can do that?

    @hadisizadiyekta125@hadisizadiyekta1252 жыл бұрын
  • But how do we leverage the low dimensional embedding given that they represent the PCA?

    @user-wr4yl7tx3w@user-wr4yl7tx3w Жыл бұрын
  • which one is the link that explains how you make the pytorch classes please?

    @mojojojo890@mojojojo89010 ай бұрын
  • Can u make a video on DNCNN

    @amzadhossain8118@amzadhossain81183 жыл бұрын
  • It should be noted that the performance difference between Linear and CNN as shown here comes from the chosen compression factor. Linear chose 12 Byte per image, CNN chose 256 Byte per image, where an original image is 784 Byte. So, the CNN code does not compress enough, less than PNG actually! You need two more linear layers to compress 64 down to 16 and then 4.

    @falklumo@falklumo Жыл бұрын
  • Bro always waiting for your pyt🔥rch video ....🤙🏼🤙🏼🤙🏼

    @saurrav3801@saurrav38013 жыл бұрын
    • 🙌

      @patloeber@patloeber3 жыл бұрын
  • your tutorials are amazing! Thank you so much... Could you please make a video for nn.embedding as well?

    @marytajz1814@marytajz18143 жыл бұрын
    • I'll have a look at it

      @patloeber@patloeber2 жыл бұрын
  • Thanks ❤

    @3stdv93@3stdv93 Жыл бұрын
  • hi, I have a question: if we pass the image as input of the model, it will put the weights to zero and then the output will be exactly the same of the input image. So, why the image is given as input of the model? It doesn't make sense to me. Could yu explain this to me?

    @marinacarnemolla5515@marinacarnemolla55152 жыл бұрын
  • How you found that the image size was decreased from 28 to 14?

    @haikbenlian5466@haikbenlian54662 жыл бұрын
  • I don't understand a little bit the sintaxis. Why do you define the method 'forward' but never call it explicitly ? Maybe the line "recon = model(img)" is where you are using it, but I didn't know that it could be done like this. I would had written "recon = model.forward(img)", is it the same ?

    @martinmayo8197@martinmayo81972 жыл бұрын
  • Beautifully explained!! thank you!

    @DiegoAndresAlvarezMarin@DiegoAndresAlvarezMarin2 жыл бұрын
  • thank you!

    @user-ie1cv8su2f@user-ie1cv8su2f2 жыл бұрын
    • You're welcome!

      @patloeber@patloeber2 жыл бұрын
  • If you normalize the input image which is also the label, the values will be between -1 to +1 but your output since passed through sigmoid will be between 0 and 1. How will you decrease loss for pixels that are between -1 to 0 as your predictions will never be less than 0?

    @khushpatelmd@khushpatelmd2 жыл бұрын
    • you need to change sigmoid function at the end to tanh, to output will also be betweet -1 to 1

      @anonim5052@anonim505228 күн бұрын
  • This channel is so underrated.Please upload tutorials about Django

    @astridbrenner2957@astridbrenner29573 жыл бұрын
  • For python 3.11+, pytorch 2.3+ change the dataiter.next() to next(dataiter)

    @maharshipathak@maharshipathak14 күн бұрын
  • Can you please show how to work with variational autoencoders and applications such as Image segmentation.

    @736939@7369392 жыл бұрын
    • will look into this!

      @patloeber@patloeber2 жыл бұрын
    • @@patloeber Thank you. Because for me it's hard to program it.

      @736939@7369392 жыл бұрын
  • why there is no require_grad there?

    @Saens406@Saens406 Жыл бұрын
  • youre the best

    @teetanrobotics5363@teetanrobotics53633 жыл бұрын
    • thanks!

      @patloeber@patloeber3 жыл бұрын
    • Could you please make GANs, VAE , transformers and BERT in pytorch

      @teetanrobotics5363@teetanrobotics53633 жыл бұрын
  • I tried to rerun your code in the part of Autoencoder CNN, but then I got Loss = nan in each epoch. Do you know what is wrong?

    @avivalviannur5610@avivalviannur56107 ай бұрын
  • Do you have anything specific for face images, this won't work on face images.

    @YounasKhan-vm8nr@YounasKhan-vm8nrАй бұрын
  • Very nice but need more

    @ArponBiswas-wq3sh@ArponBiswas-wq3shАй бұрын
  • module 'torch.nn' has no attribute 'ReLu' Is anyone else getting the same error

    @vallisham1756@vallisham17562 жыл бұрын
    • its ReLU

      @theupsider@theupsider2 жыл бұрын
    • @@theupsider Thanks a lot!

      @vallisham1756@vallisham17562 жыл бұрын
  • Next video is on GAN

    @AshishSingh-753@AshishSingh-7533 жыл бұрын
  • Am I the only one encountering nan values during training this ?

    @roshinroy5129@roshinroy512910 ай бұрын
    • On one of my virtual machines i also get nan values, when using torch 2.0.1. I tried a couple of stuff, but only with torch 1.12.1 it works fine. On my desktop pc it works with torch 2.0.1 though. But i do not know why.

      @pingpong3904@pingpong39049 ай бұрын
  • dude my CNN autoencoder is doing worse than the linear autoencoder, lmao

    @anirudhjoshi1607@anirudhjoshi16072 жыл бұрын
    • me too the ouputs show strange padding artefacts as well

      @marc2911@marc29119 ай бұрын
    • @@marc2911 On one of my virtual machines i also get nan values or strange artifacts, when using torch 2.0.1. I tried a couple of stuff, but only with torch 1.12.1 it works fine. On my desktop pc it works with torch 2.0.1 though. But i do not know why.

      @pingpong3904@pingpong39049 ай бұрын
  • "Jew-Pie-Tar notebook"

    @ryanhoward5999@ryanhoward5999 Жыл бұрын
KZhead