Convolutional Neural Network from Scratch | Mathematics & Python Code

Поділитися
Вставка
  • Опубліковано 29 січ 2025

КОМЕНТАРІ • 298

  • @davidk5589
    @davidk5589 2 місяці тому +8

    Super nice tutorial, very insightful!
    Small remark, a convolution is actually a correlation with a reflected kernel, not a rotated one, i.e. convolution and correlation are related by a change of variables: corr(f, k) = \sum_i=1^N f(i)k(i) then conv(f, k) = \sum_j = 1 ^ N f(i)k(N - i). In the case of a 2x2 kernel this happens to coincide with a 180 deg rotation, but this is not true in general e.g. for a 3x3 kernel a flip and 180 deg rotation are not the same. See: en.wikipedia.org/wiki/Convolution#:~:text=Some%20features%20of,the%20convolution%20operator.

    • @independentcode
      @independentcode  2 місяці тому +1

      Thanks a lot for pointing this out! I'm pinning your comment :)

  • @KCOANIKETSINGH
    @KCOANIKETSINGH 3 роки тому +253

    This is one of the best explanation of CNN on the internet for me, and that 3b1b video format is cherry on the cake. Please keep on making these videos.

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

      Yeah , for sure !

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

      Honestly, this is barely an explanation. He just showed you the steps to achieve CNN from scratch. He did not explain why we did some of the stuff we did, like the cross-correlation and stuff.

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

      @@mysticlunala8020that's what other videos out there already do. The focus of this video was how to actually put all the concepts into code concisely and intuitively.

  • @delete7316
    @delete7316 Рік тому +21

    I know it’s a bit late, but I thought I should mention how well this video is paced and structured. The listing and crossing out of what topics are to be covered makes the video very clear, concise and easy to follow.

  • @rocksbox156
    @rocksbox156 Рік тому +3

    I'm an undergrad student studying CS at Georgia Tech. This video explained the backprop in CNN's better than my professors. A true gem.

  • @vidyaviju1675
    @vidyaviju1675 Місяць тому +1

    This is THE BEST video where I completely learned about forward and backward props , in such an in depth manner! Thank you so much!!

  • @animeshpande1915
    @animeshpande1915 Рік тому +7

    After going through many blogs, this helped me just fully understand these networks. Such a great teacher you are!!!

  • @jamesnguyen3459
    @jamesnguyen3459 2 роки тому +8

    Please produce more high quality videos like this. Your 30-minute video explains CNN better than my 1-semester AI class in college

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

    I really love this explanation of CNNs. It almost makes them look easy

  • @BassMarineBeatz
    @BassMarineBeatz Рік тому +7

    This is the best and calm explanation in NNs that I have ever seen on Internet! Amazing work, definitely sharing it to my colleagues

  • @aminemeskar7564
    @aminemeskar7564 2 місяці тому

    I can't thank you enough; you made everything super simple. Please keep making these videos if you can apply the same method to machine learning models. Thank you so much.

  • @ExXGod
    @ExXGod 22 дні тому

    Best video on CNN. Period. Liked. Subscribed. Shared.

  • @coreytaylor5406
    @coreytaylor5406 2 роки тому +2

    This is too much underrated.
    Keep doing the good work. I really appreciate your contribution.

  • @JPTL-bl4js
    @JPTL-bl4js Рік тому +4

    This is for real one of the best videos related to any type of NN I've ever seen. Most videos just scratch the surface of how these NNs work, but you went deeper and in an understandable way. Congratulations and keep the good work!

  • @高振群
    @高振群 Рік тому +1

    the "from scratch" series you made is pure gold!!

  • @TenzinDayoe-vy6vu
    @TenzinDayoe-vy6vu Рік тому +6

    Cannot believe that tutorials like this exist. Thank you so much. I have been looking for a tutorial for a long time and I finally found it. This is definitely one of the best tutorials out there!

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

    I am making a CNN from scratch and I was a little bit stuck on how to find the gradients of convolutional layers but that little digression about how the equation of a convolutional layer is really just a more general version of the equation of the dense layer output really made it clear for me! This video is gold

  • @LouisDuran
    @LouisDuran 5 місяців тому

    Thank you! Thank you! Thank you! Thank you!

  • @agredo0o388
    @agredo0o388 3 роки тому +4

    Thank you!! I'm making a machine learning library from scratch for fun and I've been confused with some details that thanks to you now I understand. It's my favorite explanation of CNNs on youtube

  • @FahmiNoorFiqri
    @FahmiNoorFiqri 2 роки тому +8

    Thank you so much! I've been searching for this kind of explanation of CNN, especially the backprop process. I'll for sure cite this video in my thesis. Thank you!

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

    True that. After reading so many blogs on Medium, none could solve all my doubts. You did it. Kudos to you.

  • @joshp8820
    @joshp8820 3 місяці тому

    Thank you so much oh my god, I've been working on fully implementing a U-Net from scratch and I've been going mad trying to find the equation you reveal at 23:28, since I didn't know how to handle the multiple matrices produced by the d amounts of convolutions (I was going to guess summation but guessing felt bad). And here is this beautiful video with less than 200k views, which not only is a very very solid explanation of convolutional layers to full depth, but also contains a little puzzle piece I cannot for the life of me find anywhere else. Thank you!

    • @independentcode
      @independentcode  3 місяці тому

      Thank you for the kind words, I'm glad the video was helpful!

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

    I wouldn't have felt dumb, if i had watched this tutorial earlier
    One of the best explanation so far for me.

  • @Nightwolfjor
    @Nightwolfjor 27 днів тому

    One of the best tutorial so far, Great job

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

    This video is amazing, It really helped me understand the math behind CNNs - thank you!

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

    One of the best explanations for CNN on internet! Your channel would be Big in future.

  • @matthewhernandez9152
    @matthewhernandez9152 5 місяців тому

    This is an absolutely wonderful video you have here. Your explanations are clear and you helped out a graduate student a great bit!

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

    Finally, a tutorial where I got to know how the 3-channel RGB is being mapped mathematically into features. It is surprising to watch so many tutorials and none mentioned that for every channel there is a corresponding kernel and the summation of the convolutions was used to get the result for the next step. They all show h*w*3 and then a single 3*3 kernel. Example this video: C4W1L08 Simple Convolutional Network Example

  • @bob-ym3gk
    @bob-ym3gk 2 роки тому +1

    Great thanks!This is the clearest video about CNN's on the whole internet!😀

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

    The best explanation of CNN I have ever seen. Thank you!

  • @moopoo123
    @moopoo123 2 роки тому +2

    please please please keep making more videos. This is so insightful and relaxing to watch.

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

    You are a gifted teacher bro. I can't believe you've only got 50k views. But then again with how esoteric the content you're teaching is, it's impressive that your videos are so popular! Thank you

  • @guyco_beats
    @guyco_beats 2 роки тому +2

    this is definitely one of the better videos on the topic, surprised it doesn't have more views (:

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

    Man, I hope you channel become very huge. Thanks, this is the one of the best videos on youtube and not just about this topic, it is in general one of the best video in youtube

  • @HimanshuShekhar-e7o
    @HimanshuShekhar-e7o 4 місяці тому

    Crazy video, i haven't seen anything better in this topic !

  • @rishikasamyamfathervlogs
    @rishikasamyamfathervlogs Рік тому +1

    Amazing video, watched it multiple times. The only feedback I can give is, you can be a little more mindful of your words specifically, it felt like you were strongly implying the nature of CNNs to have a forward pass function that is more general than a FFNN which is an interpretation. Regardless, the best video I've seen on CNNs. Thank you so much

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

    I dont know if its the music but this video is incredibly calming, thanks for this!

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

    Came across this while trying to code Resnet in pure CUDA
    The best explanation on the topic!
    Great Thanks!!

  • @methsiri123
    @methsiri123 8 місяців тому

    One of the best tutorial I have gone through. Thank you so much.

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

    I've been reading about CNN and image recognition for a while to make my own one for my project idea, but never thought or found something that brought me light into how to implement a CNN, because I want to do it from scratch, with the maths and all staff.
    You have thought me a lot on 33min of video, now I know how I can make my own CNN, and also that I need to go over derivatives UwU
    Thanks a lot!!!

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

      Thank you for the kind message, I'm really glad if it helped :)

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

    Thank you so much for those tutorials. They are really clear and well explained. Pls do that in every domain you know, even if its plumbery

  • @hossamel2006
    @hossamel2006 Рік тому +2

    Numpy needs to add this operation and give it a name for real 8:46
    Edit: Ammmazing video btw!!

  • @xiangqi_in_russia
    @xiangqi_in_russia 10 місяців тому

    3b1b video format & amazing calming voice
    OMG, you are a treasure

  • @ali-ates
    @ali-ates 2 роки тому

    heavy logical equations like poetry, the only channel I activate the bell :D thanks for all.

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

    Best ever video on CNN, hats off!

  • @riccvven2078
    @riccvven2078 Місяць тому

    would be useful in future to create an outro where you give suggestions on how to implement other numbers or improve performance;like, look at this function instead of cross entropy... or smth like that; that would work like an exercise and engage us in excitement to see how you'll do it in future and differences between our codes

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

    I have started my AI journey a month back and I have lots of confusion as how these CNN are getting parameters and how is it passing through layers and why reshaping and many more queries. I give full star to clear all the doubts on this video. This is saviour for me in my AI journey.

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

    Finally understood backprop of conv. Thank you for the great video!

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

    It's really the best explanation I have ever seen about convolution neural network
    Thank you pro.

  • @VimalKumar-oy4uw
    @VimalKumar-oy4uw Рік тому

    Man , I am mind blown by your content . Such a great video 👌

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

    The best-ever tutorial. thank you.

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

    You are one of the best had ever explained this topic. Keep up your easy and succinct style. thumbs up

  • @Param3021
    @Param3021 4 місяці тому

    Very much interesting!
    Thank you for deep explanation ❤

  • @denismerigold486
    @denismerigold486 3 роки тому +11

    Your lessons are works of art!!!

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

    best video on Convolutional layer. Good job!

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

    Thanks for making this. You're really good at doing what you do.

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

    This in a very good tutorial to learn about CNN. Thank you so much.

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

    Your animation reminded me of 3Blue1Brown videos. Awesome stuffs! :)
    Thanks for sharing!

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

      It's because I'm using his library :)
      github.com/3b1b/manim

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

    I had so many aha moments here! this is awesome

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

    Thanks a lot for this video. Couldn't be more grateful!

  • @mr.anderson5077
    @mr.anderson5077 3 роки тому +1

    GREATEST LECTURE EVER ON CORE DEEP LEARNING.... THANK YOU MATE

  • @jvnganesh4943
    @jvnganesh4943 8 місяців тому

    really found this video very interesting and informative . I really appreciate it a lot. Thanks!

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

    Great video - first I saw that really shows how to thing about implementation

  • @b.v.r.r.jayasinghe415
    @b.v.r.r.jayasinghe415 Рік тому

    Best Explanation... lv ur teaching style and animations

  • @Misscrazy3957
    @Misscrazy3957 3 роки тому +4

    Perfect Perfect i like this channel. Bravo, i found what i was looking for. Really thank you Sir.💚

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

    awsome, thank you for the tutorial it really help me out to understand about cnn with easily

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

    Simply beautiful videos, days of struggling for understanding backprop has just ended. Would you be willing to make a video on transformers?

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

    This is amazing man. Very informative!

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

    best CNN video on youtube by far!

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

    Great sir !! i find about backward kernel so long time thank you

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

    very high quality video and amazing explanation!

  • @bradleyadjileye1202
    @bradleyadjileye1202 Рік тому +1

    thank you very much for this masterclass

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

    It is really help me to understand the whole concept of Convolutional Network. Especially the backpropagation. Please make some video on RNN, LSTN. Thank you.

  • @АлександрАкимов-п5г

    I feel like I don't deserve to get such content for free.. Amazing job!

  • @victorantoniotorrescastill2534
    @victorantoniotorrescastill2534 2 місяці тому +1

    Very nice video! Just a question: are pooling layers used in your model?

    • @independentcode
      @independentcode  2 місяці тому

      No pooling layers, I only used what I showed in the video :)

  • @easyBob100
    @easyBob100 2 роки тому +10

    Your "from scratch" videos are great! I was able to convert them into c++/cuda neural net classes and they work better than my old code. Thank you!
    Also, is there any way you can do one for an "Unconvolutional" layer? I would love to mess around with different types of autoencoders for images. :)

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

      Deconvolution is just a convolution, you just pick your convolved image, and use a bigger filter and add some padding.

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

      im currently working on a c++/cuda implementation aswell. how did it go?

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

    best video on cnn ever

  • @tanweerriyadh3785
    @tanweerriyadh3785 Місяць тому

    Please make a video on Recurrent Neural Networks... This was sooo goooddd!

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

    excellent video on CNN ever thanks buddy. Do more videos like this!!

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

    Wait what?! You only have 4 videos? No no no no we need more "from scratch" videos

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

    You could implement the hypermatrix operation you talked about in the beginning of the video in order to simplify the forward and backward functions of the Convolutional layer, removing all the loops

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

    Exceptional explanation, thank you for sharing this.

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

    Thank you for your time and effort, this is the best so far for me

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

    Everything well explained, thank you. I think all the code still can be simplified and made faster by using numpy ndarray functionalties. Instead of using all data sets in each epoch just use batches of data so that you can train all set without needing using only two class of data. Using numpy ndarray functions will remove almost all loops and hence your code will be faster.

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

      Your just hiding the loops in the function call

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

      @@polyfoxgames9006 No.Not really. Most of numpy functions are optimized C functions.

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

      @@polyfoxgames9006 Vectorized Python code can be as fast as C or Julia.

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

      @@michaelpieters1844 no way haha. Pytorch is fast because it is cuda, being called by python

  • @samarthdhingra7474
    @samarthdhingra7474 Місяць тому

    2:01 the formula is given to be y=i-k+1
    as the stride is one but there is no existence of it in the example given

  • @erron7682
    @erron7682 3 роки тому +4

    Thanks a lot!

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

    Another piece of art! Thank you

  • @אורהארבל
    @אורהארבל 2 роки тому

    Thank you so much of those two excellent videos !!!

  • @babakshiri7270
    @babakshiri7270 10 місяців тому

    Thanks, This vidio was perfect also had some beauty of mathematics

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

    Thank you for this! great explaination.
    I will request you to do "Attention" next if possible.

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

    Wow super impressive. Actually the only presentation on the internet of how actually CNN is built.
    What was your source of information? Some CNN science papers? Or any book?

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

    This is extremely in-depth and just what I needed... All the best for future videos..

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

    Just amazing work ❤

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

    Thank you for explaining very clearly!

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

    Incredible video!

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

    Really a great video ❤️❤️ I also liked the neural network video very much bcz it cleared all my doubts and I was really amazed to see how we can easily implement a network by building each layer in the internet there are many implementations but this one is the best and easiest one and this CNN is the most amazing video bcz I haven't found any article where CNN is explained in such depth it was a great video🔥🔥🔥animations are also really helpful specially its 3b1b style is one thing i liked very much. I have a request that you should also make a video on RNN bcz after watching this video I think there are many deep understanding in RNN which I don:t know and also the implementation will be really helpful.

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

    Highest quality I have ever seen. At 23:45, shouldn't the sum go from i =1 to i = d (not n ). Thank you for such a great video, I hope you find the time to continue explaining these kind of topics.

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

      Thank you :)
      Notice there is Yi in the sum, and Y goes from Y1 to Yd. There are d equations, with n terms in each.

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

      ​@@independentcode Sorry to contradict you but if you see the equation at 23:40, i goes from 1 to d (j is fixed, going from 1 to n input channels). Then in 23:45, i goes now from 1 to n, so Yi goes from Y1 to Yn, but there are not Yn elements.
      For each input channel, we need d terms in the sum because Xj contributes to all Ys.

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

      @@chinin97 My bad I was actually looking at the wrong part of the video, few seconds before. You are correct, 23:45 should be i=0 to d. Thanks for pointing this out :)

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

      ​@@omaraflak Perfect, no problem 😀. Thank you again for the quality of your explanation!

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

    BEST video! Thanks a ton!

  • @shivu.sonwane4429
    @shivu.sonwane4429 3 роки тому

    Wonderful explaination love from India🇮🇳

  • @Rohit-fr2ky
    @Rohit-fr2ky 2 роки тому +9

    Wow your content is super awesome,
    it would be super cool if you would also code RNN, LSTM, GRU and all that.. 🙂

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

    your bias term depends on the input size, which would be nice to mention