PyTorch Tutorial 14 - Convolutional Neural Network (CNN)

Поделиться
HTML-код
  • Опубликовано: 5 июл 2024
  • New Tutorial series about Deep Learning with PyTorch!
    ⭐ Check out Tabnine, the FREE AI-powered code completion tool I use to help me code faster: www.tabnine.com/?... *
    In this part we will implement our first convolutional neural network (CNN) that can do image classification based on the famous CIFAR-10 dataset.
    We will learn:
    - Architecture of CNNs
    - Convolutional Filter
    - Max Pooling
    - Determine the correct layer size
    - Implement the CNN architecture in PyTorch
    📚 Get my FREE NumPy Handbook:
    www.python-engineer.com/numpy...
    📓 Notebooks available on Patreon:
    / patrickloeber
    ⭐ Join Our Discord : / discord
    Part 14: Convolutional Neural Network (CNN)
    If you enjoyed this video, please subscribe to the channel!
    Official website:
    pytorch.org/
    Part 01:
    • PyTorch Tutorial 01 - ...
    More about CNNs:
    deeplizard channel: • Convolutional Neural N...
    Stanford Lecture: • Lecture 5 | Convolutio...
    cs231n.github.io/convolutional...
    machinelearningmastery.com/co...
    Code for this tutorial series:
    github.com/patrickloeber/pyto...
    You can find me here:
    Website: www.python-engineer.com
    Twitter: / patloeber
    GitHub: github.com/patrickloeber
    #Python #DeepLearning #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! 🙏

Комментарии • 185

  • @normalperson1130
    @normalperson1130 4 года назад +200

    Dude. Please continue to upload. Ik you don't get that many views. But there is shortage of Pytorch videos and your video are helpful for me. I hope the algorithm kicks in and your video is suggested to more people..

    • @patloeber
      @patloeber  4 года назад +30

      Thank you! Yes I will continue :)

    • @ChaojianZhang
      @ChaojianZhang 3 года назад +2

      Honestly, his is the best I have seen on CNN so far. Short and concise. Clear and straightforward.

    • @ChaojianZhang
      @ChaojianZhang 3 года назад

      Serves as a good reference video for the programming aspect. Some of the convolution math stuff is clearly skipped in this video.

    • @H3K36ME3
      @H3K36ME3 3 года назад

      This is an amazingly useful channel, thanks for your awesome work!

    • @ngunyi101
      @ngunyi101 Год назад +2

      you said he's not getting that many views? :D how times change. consistency is key

  • @iEdp526_01
    @iEdp526_01 Год назад +8

    Hey, just wanted to let you know how much these videos helped me. I started working to learn ML three years ago and now, as I'm about to graduate, have come to the point of independently building and training nets for my Undergrad Senior Project. I don't think I ever would have gotten off the ground if not for these and even now reference them when I'm starting with new types of nets or data prep. Thanks for all the time and effort you put into these.

  • @juvanthomas7022
    @juvanthomas7022 4 года назад +47

    This series of tutorial is my foundation of pytorch , These tutorials stands above all i watched . Thank You very much author. Waiting for more uploads. :)

    • @patloeber
      @patloeber  4 года назад +5

      Thank you so much for the feedback! I'm really glad that you like it and it is helpful!

  • @Hazarth
    @Hazarth 4 года назад +3

    Your videos are hands down the best step by step explanation of pyTorch, machine learning and the math behind it! I'm very thankful that you make this series, you're amazing and I wish you a great day!

    • @patloeber
      @patloeber  4 года назад

      Thank you so much :)

  • @scoburto1
    @scoburto1 3 года назад +8

    Especially liked the explanation of how the size of the torch tensor changes through the layers of the ConvNet. Thanks for sharing!

    • @patloeber
      @patloeber  3 года назад +1

      Thanks, happy to hear that!

  • @ferencfeher7094
    @ferencfeher7094 3 года назад +10

    This equation saved me. I am literally in a masters program and I was struggling with getting the right number of dimensions. Not anymore thanks to you!!

    • @patloeber
      @patloeber  3 года назад

      Glad to hear that :)

  • @sanderg9106
    @sanderg9106 3 года назад +11

    I am starting with pytorch and this video saved me from anxiety and despair :)

  • @aidankennedy6973
    @aidankennedy6973 3 года назад

    This, as with all videos on this channel, needs more views. Every time I need to learn something on ML, this channel has the best and most enjoyable videos.

  • @porkfisher1030
    @porkfisher1030 Месяц назад

    You have saved my Nature Inspired Computing assignment!!! Thank you soooo much! Fantastic demonstration and clarity! Amazing 😆

  • @conlanrios
    @conlanrios 5 месяцев назад

    Thank you! This finally helped me understand what was going on between convolutional layers.

  • @MarcinAKGaming
    @MarcinAKGaming 3 года назад +1

    Awesome tutorial. Helped me understand so many concepts I need for a college level ML course in 20 minutes. Thanks!

    • @patloeber
      @patloeber  3 года назад

      Glad you enjoyed it!

  • @user-vp2jc7fi5q
    @user-vp2jc7fi5q 10 месяцев назад

    You uploaded 3 years ago and im so glad you did, university didnt teach this much istg THANKS ALLOT !!!! KEEP UPLOADING MORE. and tell a toolkit other than cuda for intel UHD graphics

  • @jh6643
    @jh6643 4 года назад

    Great tutorials. Making sure that I don't leave without liking these videos.

  • @summerxia7474
    @summerxia7474 2 года назад

    The best CNN python video!!! Thank you so much!!!

  • @saruaralam2723
    @saruaralam2723 4 года назад +5

    your teaching style/flow is great,(theory and coding at the same time), kindly upload more regarding other DL frameworks/platforms like tensorflow, keras, etc.

    • @patloeber
      @patloeber  4 года назад

      Thank you! I'm glad that you like it!

  • @longnguyenhoang764
    @longnguyenhoang764 2 года назад +1

    your course is saving my life, EVERY SINGLE VIDEO is a gold material

    • @amiprogramming4897
      @amiprogramming4897 Год назад

      Hey, I just came across your comment on the PyTorch Geometric tutorial lol

    • @aytida754
      @aytida754 Месяц назад

      @@amiprogramming4897 Hey, I just came across your reply to a comment on the PyTorch Geometric tutorial lol

  • @erfanshayegani3693
    @erfanshayegani3693 Год назад

    You are the best considering the strength of explanation!

  • @nougatschnitte8403
    @nougatschnitte8403 2 года назад

    Writing my Bachelor thesis about this, you are a life saver :-)

  • @paulntalo1425
    @paulntalo1425 2 года назад

    Awasome precise and insighful tutorials, indeed the best about PyTorch and CNN. Thank you

    • @patloeber
      @patloeber  2 года назад +1

      Glad you like them!

  • @fahadaslam820
    @fahadaslam820 4 года назад +5

    Do you have an example of CNN implementation on 1D data? for example CNN model for 'Wine Dataset you have used in your tutorial'?
    Thanks!

  • @suryavaraprasadalla8511
    @suryavaraprasadalla8511 2 года назад

    keep going. Please continue to upload. Great Content and support.

  • @polouabcoite
    @polouabcoite 3 года назад

    Thank you so much! Your videos are helping me a lot. Congratulations!!

  • @diegocassinera
    @diegocassinera Год назад +1

    Great Video . One simple question, you explain very well how the hardcoded values came to be. Could the values for the inner layers (pool, conv2, fc1, fc2,...) be obtained programmatically from the previous layer ?

  • @asrafpatoary4127
    @asrafpatoary4127 2 года назад

    I am studying at FAU and watching your videos to crack the coding part of DL exam ✌

  • @summerpiao2299
    @summerpiao2299 3 года назад

    Hi, I just want to thank you for your work. I think those videos are really helpful to me and we are very appreciative of those. :-D They are really useful and you have a clear explaining structure. Thank you a lot!

  • @BalajiOm
    @BalajiOm 3 года назад

    Very helpful! Thanks for the video

  • @anuragshrivastava7855
    @anuragshrivastava7855 2 года назад

    please upload more advance pytorch videos and projects and keep doing great work

  • @CPjonesn
    @CPjonesn 2 года назад

    Loved the video as always, thank you! Short question: I was wondering how you came (or have been comming) up with the simple CNN architecture(s), is this for example a common vanilla network or do you maybe have a paper at hand that you use. Would be interesting to know. Thanks ahead - big fan!

  • @twahirabasi9765
    @twahirabasi9765 3 года назад +1

    The best tutorial!, thank you so much!

  • @Deathend
    @Deathend 2 года назад

    Thank you for the tutorial as well as the github. I need to mess around with things to get a solid grasp of them so I greatly appreciate this. :D

  • @canernm
    @canernm 3 года назад

    Hello! Thanks for the videos. Quick question: i've seen people use the methods "model.train()" and "model.eval()". Can you tell me why they are not necessary here? Thank you in advance!

  • @user-pt9lb4rz7u
    @user-pt9lb4rz7u 4 месяца назад

    Thank you for this video!

  • @prajganesh
    @prajganesh 4 года назад +1

    have a basic question. When Forward and background propagation happens, does it enumerate any number of time back and forth to go to minimize loss or do we need to iterate in a loop? So the training loop is for each image, but then the Forward and Backward goes any number of times to optimize, correct?

    • @patloeber
      @patloeber  4 года назад +1

      training loop is for the number of epochs we specify. and then for each epoch we iterate over our data and take batch samples. For each batch we do a forward and backward pass then.

  • @yannickleroy7419
    @yannickleroy7419 2 года назад

    Awesome video thank you very much!

  • @user-xp4uw2kc3n
    @user-xp4uw2kc3n 4 месяца назад

    Thanks it was very helpful! if we want to add one more convolution layer what its argument number will be?

  • @tumultuousgamer
    @tumultuousgamer 2 года назад

    Could you please clarify why you flatten to columns instead of rows i.e. x.view(-1, 16 * 5 * 5) instead of x.view(16*5*5, -1). In my program, I noticed that there are errors like NaN happening when I flatten to rows (with a higher learning rate of 0.5), rather than columns. Seems like you have done this for some reason, could you please explain it?

  • @divymohanrai
    @divymohanrai 3 года назад +1

    Really great tutorial. I had a question regarding the values for mean and std(). How did you choose the value of mean to be 0.5 for all channels and the same for standard deviation? Did you precompute it?

    • @patloeber
      @patloeber  3 года назад +2

      This is approximately the mean over each channel of the training data set (yes precomputed).

  • @MontanaPreston
    @MontanaPreston 3 года назад

    Very helpful, thank you!

  • @tianzongwang6832
    @tianzongwang6832 4 года назад

    Very clear implementation!

  • @georgianaorbeanu9179
    @georgianaorbeanu9179 2 года назад

    Great video! Keep it up!

  • @michaelmuolokwu5039
    @michaelmuolokwu5039 2 года назад

    I really love your videos

  • @tobi9668
    @tobi9668 3 года назад

    Why do you choose 6 and 16 for ouput size in conv layer? Is this just trying out what works the best? I read when the image has more features the outputsize should be greater. Is this correct? Would be size if you do some more content about cnn or gan

  • @parthkandwal8343
    @parthkandwal8343 2 года назад

    Great work
    Thank you very much

  • @hjr0021
    @hjr0021 3 года назад +1

    Please do a video on the implementation of Conv1D for multi class classification.

  • @jieluo3736
    @jieluo3736 3 года назад

    your videos are really good, thank you

    • @patloeber
      @patloeber  3 года назад

      thanks for watching :)

  • @TusharFaroque
    @TusharFaroque 3 года назад

    *Wow, Thanks a lot brother*

  • @rutvikjaiswal4986
    @rutvikjaiswal4986 3 года назад

    This video really want to goes in trading page sir your teaching style is awesome ! you are too cool thank your for this video . I fall in love with your teaching

    • @patloeber
      @patloeber  3 года назад +1

      thanks a lot! happy to hear this

  • @ottorocket03
    @ottorocket03 2 года назад

    On 14.03, what if we have multiple filters, i.e 4 filters with size of 3 x 3 ? Does the equation change ?

  • @userwheretogo
    @userwheretogo 2 года назад

    What is the difference between view and reshape? reshape was used in FFN video and view is used here. Thanks!

  • @sinemozdemir3884
    @sinemozdemir3884 2 года назад

    thank you, very good explanation.

  • @TheOraware
    @TheOraware 3 года назад +8

    thanks for such a detailed video , why did you chose output channel size is 6 at 8:32? is it just an arbitrary?

    • @alperensonmez6875
      @alperensonmez6875 2 года назад

      I couldn't get it either

    • @anonymousanon4822
      @anonymousanon4822 2 года назад +1

      Yes, it's arbitrary. Basically the amount of output channely determines how many different convolutional filters are used. So more filters allow the neural network to maybe implement a vertical edge finding filter, one for horizontal edges, 2 for diagonals, and more. The downside is that more channels mean more weights, which makes the network harder/slower to train.

  • @user-er3vj8cl9l
    @user-er3vj8cl9l Год назад

    wow its very awesome thx :)

  • @user-fk1wo2ys3b
    @user-fk1wo2ys3b 3 года назад

    Superb job!

  • @mohaiyedin
    @mohaiyedin 3 года назад

    Great video... Thanks for sharing...

    • @patloeber
      @patloeber  3 года назад

      glad you liked it :)

  • @anthonynguyen6293
    @anthonynguyen6293 4 года назад +2

    can you explain a little bit more on how you decide the output channel and the kernel size? And also the input/output sizes of the fully connected layers please.

    • @patloeber
      @patloeber  4 года назад

      Very good question. The architecture in my video is taken from the popular LeNet-5 network. You can read more here:
      medium.com/datadriveninvestor/five-powerful-cnn-architectures-b939c9ddd57b

  • @igor-policee
    @igor-policee 2 года назад

    Hello! I always look at your work carefully and I want to thank you for what you do!
    I have one question about the code. Please explain why you use exactly such parameters in: transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)). Thank you!

    • @patloeber
      @patloeber  2 года назад

      these are the mean and std dev that were calculated previously from the training data

  • @aomo5293
    @aomo5293 Год назад

    Hi, Thank you for great video;
    Please have y made before an example on which you show how to load images from local directory + labels from extrac csv or pkl file ?
    Thank you

  • @chandanagrawal2399
    @chandanagrawal2399 4 года назад +1

    Very clear explaination.. Plz also consider making a tutorial on using GPUs with pytorch.. It would be very helpful

    • @patloeber
      @patloeber  4 года назад +2

      Thank you! All the code in my tutorials should work on GPUs, too, since we are sending model and tensors to the GPU device if it is available.

  • @valarmorghulisx
    @valarmorghulisx 3 года назад

    hi! Thank you so much for this awesome tutorials. we calculate the n_total_steps = len(train_loader). why is the train loader length is 12500? where did we define it?

    • @builder_Max
      @builder_Max Год назад +1

      It's defined at train_loader = torch.utils.data.DataLoader(trainset, batch_size=batch_size, shuffle=True). As you set batch_size as 4 here, it divides the total number of data(50000) by 4 and becomes 12500.

  • @juanete69
    @juanete69 2 года назад

    Hello. Is it the same a "train_loader" than a minibatch?

  • @prajganesh
    @prajganesh 4 года назад +1

    Is it possible to show how to train our own images and identify? For fun, I want to load all my local pictures and separate into folder based on the images it sees. Do we have any examples?

    • @patloeber
      @patloeber  4 года назад +1

      have a look at tutorial 15. there i load saved images from folders

  • @MRexlit3
    @MRexlit3 3 года назад

    Hi, I am currently doing work which involves creating a CNN. We have to give it an input channel of 3*128*128. Does this just mean I set the Channel parameter in the Conv2d to 3, and the images are 128*128? Or do I need to set parameters as 128 somewhere

    • @nothinghere3702
      @nothinghere3702 3 года назад +1

      Images are 128*128 pixel
      And 3 indicates it’s a colored images (R,G,B).

  • @nateshtyagi
    @nateshtyagi 3 года назад

    Excellent work but I want to know will this model work on a dataset that has classes that aren't mutually exclusive? For ex: Street View House Number Dataset (SVHN).

    • @patloeber
      @patloeber  3 года назад

      nope for SVHN you have to adapt the model and probably use object detection first, then classify each digit separately

  • @sergiomurilo758
    @sergiomurilo758 3 года назад

    Dude...can't thank you enough....You saved my life hehe

    • @patloeber
      @patloeber  3 года назад

      haha glad to hear that :)

  • @saltanatkhalyk3397
    @saltanatkhalyk3397 2 года назад

    Thank you good man

  • @skyacaniadev2229
    @skyacaniadev2229 3 месяца назад

    ​ @patloeber Is it a typo in the learning rate? I used 0.01 (instead of your 0.001), and the accuracy is much better (65%).

  • @ranjanrajdahal3557
    @ranjanrajdahal3557 5 месяцев назад

    This is outstanding . can anyone know how the earthquake time series data can be trained to CNN ?
    any video
    please help

  • @davidwu3247
    @davidwu3247 2 года назад

    you are a LIFESAVER

    • @patloeber
      @patloeber  2 года назад

      happy to hear that :)

  • @Chiro13
    @Chiro13 2 года назад

    hi, the Conv2d has the Relu activation?

  • @tarekradwan8661
    @tarekradwan8661 3 года назад +1

    when you use transforms.Normalize(.....) shouldn't each channel in the image be normalized to [0,1] before you can set a mean and std of 0.5??

    • @patloeber
      @patloeber  3 года назад +1

      Good point! All torchvision datasets are PILImage images of range [0, 1], so it's already scaled :)

  • @moshoodolawale3591
    @moshoodolawale3591 4 года назад

    What theme are you using on visual code studio and likely tips and tricks for running the code within your environment in general?

    • @patloeber
      @patloeber  4 года назад +1

      It's the night owl theme. I'm planning to do a tutorial about my vs code setup

    • @moshoodolawale3591
      @moshoodolawale3591 4 года назад

      @@patloeber That would be great

  • @johnparker2486
    @johnparker2486 4 года назад

    You are amazing!

  • @nicolasgabrielsantanaramos291
    @nicolasgabrielsantanaramos291 4 года назад

    Is it possible to use time series as input data ? Do you indicate any link to read more about ? And, thanks a lot for the class, it help me a lot.

    • @patloeber
      @patloeber  4 года назад +1

      Sure you can.
      machinelearningmastery.com/how-to-develop-convolutional-neural-network-models-for-time-series-forecasting/
      towardsdatascience.com/how-to-use-convolutional-neural-networks-for-time-series-classification-56b1b0a07a57

    • @nicolasgabrielsantanaramos291
      @nicolasgabrielsantanaramos291 4 года назад

      @@patloeber thanks!!!!

  • @chootzesien9315
    @chootzesien9315 3 года назад

    Hi! May I know why the optimizer.zero_grad() is place before the optimizer.step()? Previous episode it was place after the optimizer.step()

    • @patloeber
      @patloeber  3 года назад +1

      does not really matter as long as it's called before the next iteration

  • @tristanc.6598
    @tristanc.6598 8 месяцев назад

    Why was the output channel size on the second conv layer 16?

  • @popamaji
    @popamaji 4 года назад

    13:20 why did u increased the colour channel numbers and what does it mean even?

    • @patloeber
      @patloeber  4 года назад +2

      The architecture is taken from the popular LeNet-5. It means we get 6 feature maps as output. medium.com/datadriveninvestor/five-powerful-cnn-architectures-b939c9ddd57b

  • @raminessalat9803
    @raminessalat9803 3 года назад

    Hey Great video! have a question: what is the reason for the normalization 0.5 in the transform option for?

    • @patloeber
      @patloeber  3 года назад +1

      That’s roughly the mean value of the training dataset (which I pre-calculated). Using this will normalize the whole dataset to have the same mean

    • @raminessalat9803
      @raminessalat9803 3 года назад

      @@patloeber Great! thanks!

  • @amankushwaha8927
    @amankushwaha8927 2 года назад

    Thanks

  • @epistemicompute
    @epistemicompute Год назад

    I am confused, why doesn't max pooling change the input dimension of the next convolution layer?

  • @amareshdhal516
    @amareshdhal516 3 года назад +1

    Why the output channel is 6 at 8.35.

  • @iposipos9342
    @iposipos9342 4 года назад +1

    Thanks for your video. I find this a little confusing. Please what is the difference between conv1D, conv2D and conv3D and in what context should we use each of them? thank you

    • @patloeber
      @patloeber  4 года назад +2

      Good question! Most of the time we are dealing with conv2D since our images are most likely 2-dimensional. Maybe this link is helpful : stackoverflow.com/questions/42883547/intuitive-understanding-of-1d-2d-and-3d-convolutions-in-convolutional-neural-n

    • @iposipos9342
      @iposipos9342 4 года назад

      @@patloeber thanks

  • @sailfromsurigao
    @sailfromsurigao 3 года назад +1

    Why not use flatten layer?

  • @theonethatcant
    @theonethatcant 4 года назад

    Why do you perform optimizer.zero_grad() before the loss.backward() and optimiser.step()? It conflicts with your previous videos and seems counter-intuitive as I assumed the backward step uses the gradients resulting in the forward step.

    • @patloeber
      @patloeber  4 года назад

      It does not matter if you call zero_grad at the end or at the beginning of the for loop. Just make sure that the gradients are empty before the next backward() call. I should have been more consistent in my code...

  • @yashvander-bamel
    @yashvander-bamel 2 года назад

    There is one question though, do we need to keep track of the shapes after each convolution and/or pooling layer? So that we can enter the correct amount of input neurons in the first Linear layer. Isn't there a convenient method for this?
    BTW Thanks for the awesome tutorial !!

    • @pratyushsingh7062
      @pratyushsingh7062 2 года назад

      Yes, you need to calculate that manually

    • @yashvander-bamel
      @yashvander-bamel 2 года назад

      @@pratyushsingh7062 Have a look at lazy layers in pytorch. You might want to change your opinion then.

  • @teetanrobotics5363
    @teetanrobotics5363 4 года назад +2

    you missed RNN and LSTM. But still an amazing playlist

    • @patloeber
      @patloeber  4 года назад +5

      I know. I plan to do them in the future

  • @aliikram4993
    @aliikram4993 3 года назад

    what if i want to do this but with a data which is not one of the torchvision datasets how would I load it then

    • @patloeber
      @patloeber  3 года назад

      probably implement your own Dataloader like I explained in lesson 9

  • @elise8619
    @elise8619 Год назад

    May I ask why you don't just use nn.Sequential to define the model? It is much more straightforward and easier to read I think. Or perhaps this is a newer feature? Anyway, for anyone interested, I just replaced the class definition with:
    model = nn.Sequential(
    nn.Conv2d(3,6,5,stride=1),
    nn.ReLU(),
    nn.MaxPool2d(2,2),
    nn.Conv2d(6,16,5,stride=1),
    nn.ReLU(),
    nn.MaxPool2d(2,2),
    nn.Flatten(),
    nn.Linear(16*5*5,120),
    nn.ReLU(),
    nn.Linear(120,84),
    nn.ReLU(),
    nn.Linear(84,10)
    ).to(device)

  • @back81192
    @back81192 4 года назад

    I was wondering when did you call the forward function that you defined in the class? It seems that you didn't call it...

    • @patloeber
      @patloeber  4 года назад +2

      The forward pass will be executed for you when you call outputs = model(images). For this you have to define it in your model class

    • @back81192
      @back81192 4 года назад +1

      @@patloeber thanks

  • @chakra-ai
    @chakra-ai 3 года назад

    Hi, I request, Can you please add a NLP use case to this series of pytorch implementation.

    • @patloeber
      @patloeber  3 года назад +1

      Definitely want to do this. For now I already have a chat bot tutorial (4 videos) with PyTorch that teaches some beginner NLP techniques

  • @prashantsharmastunning
    @prashantsharmastunning 4 года назад

    so we can randomly choose output_channel for each CNN layer?!! does it affect the accuracy?

    • @patloeber
      @patloeber  4 года назад +2

      Hi! Different architectures of course affects the accuracy. the architecture in this video is taken from the popular LeNet-5. I did not go too much into detail when talking about the architecture. If you are interested you can read more here: medium.com/datadriveninvestor/five-powerful-cnn-architectures-b939c9ddd57b

    • @prashantsharmastunning
      @prashantsharmastunning 4 года назад +1

      @@patloeber thanks this was really helpful..

  • @aleenasuhail4309
    @aleenasuhail4309 3 года назад

    I have a cov network:
    net = nn.Sequential(
    nn.Conv2d(3,10, kernel_size=5, padding=0),
    nn.ReLU(),
    nn.MaxPool2d(kernel_size=2, stride=2),
    nn.Conv2d(10,16, kernel_size=5, padding=0),
    nn.ReLU(),
    nn.MaxPool2d(kernel_size=2, stride=2),
    nn.Flatten(),
    nn.Linear(16*5*5,120),
    nn.ReLU(),
    nn.Linear(120,10)
    )
    for param in net.parameters():
    print(param.shape)
    but I am getting an error when trying to train it the error is:
    mat1 and mat2 shapes cannot be multiplied (64x13456 and 400x120)
    could you please help

    • @robinswamidasan
      @robinswamidasan 3 года назад

      Clearly the size of the output from the 2nd MaxPool2D is not 16*5*5. What is the size of your input image? It's clear that it has 3 channels, but what is size of the data per channel (e.g. # of pixels: m x n). The input to Linear will depend on this size.

  • @manalihiremath2805
    @manalihiremath2805 3 года назад

    i am getting tis error:Given groups=1, weight of size [20, 15, 3, 3], expected input[32, 3, 256, 256] to have 15 channels, but got 3 channels instead

    • @patloeber
      @patloeber  3 года назад

      compare with my code on github. somewhere you have an error with the wrong size

  • @R3nxt
    @R3nxt 4 года назад

    Great

  • @VarunKumar-pz5si
    @VarunKumar-pz5si 3 года назад

    Why you normalized the data from [0,1] to [-1,1]

  • @akhileshsingh569
    @akhileshsingh569 3 года назад

    How do you calculate there are 6 output channel

    • @patloeber
      @patloeber  3 года назад

      the architecture in this video is taken from the popular LeNet-5. I did not go too much into detail when talking about the architecture. If you are interested you can read more here: medium.com/datadriveninvestor/five-powerful-cnn-architectures-b939c9ddd57b

  • @saurrav3801
    @saurrav3801 3 года назад +1

    Bro how to find image standard deviation and mean of image channels..

    • @patloeber
      @patloeber  3 года назад +2

      This is just the pre-calculated mean and stddev of the training dataset.

  • @HanWang_
    @HanWang_ Год назад

    Thank you so much! Everything is so clear. And even though English is not my mother tongue, I can catch up without caption. (*^_^*)

  • @lakeguy65616
    @lakeguy65616 3 года назад +1

    I followed your code exactly. I trained for 20 epochs and achieved overall accuracy of 63%. So I trained for 100 epochs and the accuracy went down to 60.75%. What accuracy can be achieved? what is the highest accuracy you have reached? thank you for responding.

    • @patloeber
      @patloeber  3 года назад

      I used just a basic model in this tutorial. I recommend to follow tutorial #15 and use transfer learning on CIFAR10 and then see how well it performs

    • @lakeguy65616
      @lakeguy65616 3 года назад

      I have tested the simple ff model from #13 with different hidden layers 1 through 4 and different numbers of neurons per layer (25 - 3000).

  • @kerrsv
    @kerrsv 5 дней назад

    Did you forget a 2nd pooling layer?

  • @TechnGizmos
    @TechnGizmos 3 года назад +1

    Very clean and intuitive explanation on why 16*5*5 is the input for the 1st Fully Connected layer, but something isn't adding up for me.
    In your ConvNet class you've used conv1, pool and conv2. But in your cnntest.py script you've called conv1, pool, conv2 and an additional pool. Without the extra pool, the dimensions would be 16*10*10 which should be the actual input parameter in the ConvNet class(if you're going to use 3 layers).
    I'm just a beginner in neural networks, so I'm not sure whether this was intentional, although it could explain why the accuracy of your model was pretty low(due to an incorrect representation passed down to the following layers). Let me know your thoughts.

    • @patloeber
      @patloeber  3 года назад

      Thanks for watching! No, watch closely from minute 18:00 where I implement the forward pass. I apply 2 times self.pool(). But note that I defined only one pool in the __init__() because we use exactly the same 2x2 pool and can therefore use the same one again

    • @TechnGizmos
      @TechnGizmos 3 года назад

      @@patloeber Saw it...my bad. Thanks for clarifying.

    • @patloeber
      @patloeber  3 года назад

      @@TechnGizmos No problem :)