Pytorch Transfer Learning and Fine Tuning Tutorial

preview_player
Показать описание
In this tutorial we show how to do transfer learning and fine tuning in Pytorch!

❤️ Support the channel ❤️

Paid Courses I recommend for learning (affiliate links, no extra cost for you):

✨ Free Resources that are great:

💻 My Deep Learning Setup and Recording Setup:

GitHub Repository:

✅ One-Time Donations:

▶️ You Can Connect with me on:
Рекомендации по теме
Комментарии
Автор

Thank you so much! You set me free from the PyTorch documentation! Your videos deserve more thumb up!

ruotianzhang
Автор

I'm from Barcelona and I love you, thanks for your work.

victorsuarezvara
Автор

Thank you! Even after having used PyTorch for some years there is always something new to learn in your videos :)

rodrigolopezportillo
Автор

Thank you so much man, this helped me understand some of the logics I was facing trouble with.

googlable
Автор

Thank you for a great explanation Aladdin.

Just a quick question, regarding the model that you referred to in your video, the one with the 89% accuracy 8:15 . I couldnt find it in the previous video. Can you tell me which video were you referring to?

alesani
Автор

in line 31 we can freeze using model.parameters()[-2] this will give us 2 more layers to modify their parameters

donfeto
Автор

Hi and thank you for the detailed video :) I do have one question: you showcase how we can freeze the entire VGG pretrained model. How can someone freeze part of the VGG model though? For example, leave the last 5 layers of the 'features' part trainable. I'd have to alter the for-loop you used so as to affect only the parameters corresponding to the layers I am interested in changing?

Thanks.

canernm
Автор

I don't understand the average pooling part. why u changed it to identity? I've re-watch that part so many times but still got no idea why u did that

owenlie
Автор

Great! Could you make tutorial pretrained resnet34 for UNet encoder?

anastasiaberlianna
Автор

Can't we replace what you did with your Identity class with nn.Identity() from doc?
Thank you.

hizircanbayram
Автор

I would like to know how the model understands to finetune only the classifier part by only writing: for param in model.parameters():
param.requires_grad = False ?
Do I need to specify optimizer = optim.Adam(model.classifier.parameters(), lr=learning_rate) as it is to make sure to only finetune classifier layer ?
Thanks :) 👍

elifcerengok
Автор

should one use spyder or pycharm? What do you recommend?
Thanks in advance

gorkemcanates
Автор

I did't understand the identity part, can u pls exa\plain it, what it does?

codewithyouml
Автор

I have a question, what situation it is when the accuracy is 53% 63% 89% respectively, when pretrained=False, does it mean VGG train from scratch?

yixinwu
Автор

VGG16 has 5 max_pool and the conv_layers do not change the image shape, which will reduce the image size to 224/(2**5)=7. So, the input size for the first nn.Linear should be 512*7*7 = 25088 (we can see this in the original VGG16 at classifier[0] 4:15). While after changing the avg_pool to Identity, the first linear layer of nn.Linear(512, 10) worked, as in this video, but nn.Linear(512*7*7, 10) failed. I can't figure out the reason. Can you help me with this?

### Further experiment ###
If not replace the avg_pool to Identity (i.e, only modify the classifier layers), then the first linear layer of nn.Linear(512*7*7, 10) worked but nn.Linear(512, 10) failed. This looks even stranger to me as it indicating the Identity layer shrinks the image size from 7*7 to 1*1. Really don't know why this happens.

JinzhuWANG
Автор

Earlier fully connected layer took input of 25088 dimension, but now the fully connected layer is taking input of 512 dimension. so, the code should return error right? as adaptive.avrpool2d takes 512*7*7 as input and gives 512*7*7 as output

CHANDANSAH-ewrk
Автор

Hi, I tried to run your code but I keep getting Runtime error: CUDA error: device-side assert triggered, in line 'model.to(device)', may I know what is the problem of that error? Thanks!

jericho
Автор

hi bro, for the last part, just training last classifier, need we write this" optimizer = " or just in your way or both of them are ok ?

ximingdong
Автор

Thank you so much! I have a problem with my implementation.
I am using a dataset of grey-scale images (256*256) with batch_size = 5

I got a run time error during the training loop
>>

RuntimeError: Expected 4-dimensional input for 4-dimensional weight [64, 3, 3, 3], but got 3-dimensional input of size [5, 256, 256] instead

my model is pretty simple:
model.avgpool = Identity()
model.classifier = nn.Linear(512, 3)

Any help?

هاجرأسامة-وز
Автор

Hi,
I used VGG11 model for the same dataset and using the pretrained weights I trained the model. Got 24.4% accuracy on the train and approx the same for the test set which is worse compared to model which I created which had 5 layers and accuracy of >50% in first epoch. Am I doing something wrong?

eltonlobo
visit shbcf.ru