Building a neural network FROM SCRATCH (no Tensorflow/Pytorch, just numpy & math)

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

ความคิดเห็น • 1.3K

  • @khoa4k266
    @khoa4k266 11 หลายเดือนก่อน +636

    I watched this video when I was studying in grade 11. Had no clue what he was talking about but I tried to understand as much as possible.
    Now I watch it again as a university student, it is so satisfying to understand everything now.

    • @viCuber
      @viCuber 10 หลายเดือนก่อน +25

      Hope that will happen to me to

    • @CR33D404
      @CR33D404 10 หลายเดือนก่อน +4

      @@viCuber same LOL

    • @viCuber
      @viCuber 9 หลายเดือนก่อน +2

      @@CR33D404 lmao

    • @codevacaphe3763
      @codevacaphe3763 9 หลายเดือนก่อน +10

      It happens to me several time. Sometime you just stumble on a knowledge and can't understand a single thing about it then suddenly 1 or 2 years later you completely understand it without any try.

    • @nachoyawn
      @nachoyawn 8 หลายเดือนก่อน +1

      same

  • @victorafonso4534
    @victorafonso4534 2 ปีที่แล้ว +6824

    Making a neural network from scratch is easy, what I really want to see is how to make a neural network ON scratch.

    • @d3vitron779
      @d3vitron779 2 ปีที่แล้ว +688

      Make the scratch cat sentient challenge (gone wrong) (humanity destroyed)

    • @theRPGmaster
      @theRPGmaster 2 ปีที่แล้ว +199

      Just create a python interpreter in Scratch, easy

    • @Despatra
      @Despatra ปีที่แล้ว +16

      Ok

    • @v037_
      @v037_ ปีที่แล้ว +47

      Lmao, understimated comment, but perfect one

    • @BurNJoE
      @BurNJoE ปีที่แล้ว +3

      lol

  • @jumpierwolf
    @jumpierwolf 2 ปีที่แล้ว +385

    Took a Machine Learning course in university and this is what we did the whole semester in Matlab. Tensorflow was introduced right at the end for the final project.

    • @gasun1274
      @gasun1274 ปีที่แล้ว +13

      sounds amazing

    • @marshmellominiapple
      @marshmellominiapple ปีที่แล้ว +12

      oh hell yea matlab

    • @FictionHubZA
      @FictionHubZA ปีที่แล้ว +43

      ​@@marshmellominiapple oh he'll yeah methlab

    • @dumbfate
      @dumbfate ปีที่แล้ว +24

      @@FictionHubZA LET HIM COOK

    • @PluetoeInc.
      @PluetoeInc. 7 หลายเดือนก่อน

      @@dumbfate no you let him cook

  • @hcmcnae
    @hcmcnae ปีที่แล้ว +128

    I'm so glad you actually went in depth with the math explanation. So often people will just explain surface layer and then "alright lets jump into the code".

    • @Ayush-sz8ys
      @Ayush-sz8ys 4 หลายเดือนก่อน +10

      dude, he literally did the same when he explained backpropagation and labelled it as "fancy maths" instead of properly explaining it.

    • @warpdrive9229
      @warpdrive9229 2 หลายเดือนก่อน

      @@Ayush-sz8ys Exactly! He should have derived it through matrix calculus.

  • @albertolemosduran5685
    @albertolemosduran5685 2 ปีที่แล้ว +30

    Most of the videos are titled “how to create a blabla” when they’re actually teaching how to use… so I really appreciate your video! This really contributes to knowledge 🥰

  • @MegaJesusini
    @MegaJesusini ปีที่แล้ว +93

    My man really explained how a back propagated neural network works from scratch in 10 minutes

  • @you_just
    @you_just 2 ปีที่แล้ว +3599

    i like how numpy has become so ingrained in python that it's basically considered vanilla python at this point

    • @nathanwycoff4627
      @nathanwycoff4627 2 ปีที่แล้ว +89

      interestingly much of that functionality is built into other languages used by the ml community such as R, matlab and julia.

    • @mattrochford6783
      @mattrochford6783 2 ปีที่แล้ว +78

      @@nathanwycoff4627 matrices and linear algebra are really useful for math and engineering less so for general programming. Different languages focusing on different usability concerns quite interesting.

    • @machineman8920
      @machineman8920 2 ปีที่แล้ว +11

      @@mattrochford6783 stop coping julia is just a better language

    • @HilbertXVI
      @HilbertXVI 2 ปีที่แล้ว +70

      @@machineman8920 ???

    • @thebluriam
      @thebluriam 2 ปีที่แล้ว +160

      I don't like it. I wish people stopped being overly-lazy with Numpy and just wrote their own libraries so they'd understand what they are actually doing. No, scratch that, if they can't accomplish the same thing using only Assembly, they're a total noob, should put down their keyboard, and get an MBA instead...

  • @uncoded0
    @uncoded0 3 ปีที่แล้ว +818

    This video is one of the best descriptions of neural networks written in only Numpy and Python I've ever seen.
    Thanks

    • @anishojha1020
      @anishojha1020 3 ปีที่แล้ว +3

      Hey guys, a reply would be highly appreciated. I want to plot the cost vs the number of iterations but I am not able to figure which parameter to plot ? I am a beginner and I would really appreciate the help. Thank you

    • @uncoded0
      @uncoded0 3 ปีที่แล้ว +6

      @@anishojha1020 Hi, try posting comment again in regular comments part, so more people see it. This is only a sub-comment.

    • @waterspray5743
      @waterspray5743 3 ปีที่แล้ว

      @@KHM95 Hi, are you a bot?

    • @KHM95
      @KHM95 3 ปีที่แล้ว +1

      @@waterspray5743 No man, I am not.

    • @ME0WMERE
      @ME0WMERE 2 ปีที่แล้ว +1

      I advise looking at sendex's 'Neural Network from scratch' series

  • @jasonavina8135
    @jasonavina8135 2 ปีที่แล้ว +21

    In case any beginners to ML came here wondering why they are really confused, this video isn't really for beginners and he doesn't really explain that. Its "from scratch" in the sense of not using any prebuilt models in the code. Its a good explanation for people who are already familiar with neural networks, prebuilt layers, loss functions, etc. not for people starting their understanding "from scratch."

    • @OT-tn7ci
      @OT-tn7ci 2 ปีที่แล้ว +3

      actually im new to ML, (2-3 months in) and this helped me understand a lot, i am implementing it on my own now, without even using numpy so i can code out stuff like transpose on my own and learn more. Random is tricky tho lol

    • @BatPoopBatPoopBatPoop
      @BatPoopBatPoopBatPoop หลายเดือนก่อน

      @@OT-tn7ciyes but he doesn’t explain the math or why it works. It’s meant for people that already know why the math works, and who want to know how to put it all together

  • @traviss7740
    @traviss7740 2 ปีที่แล้ว +78

    I've never heard any of this explained before. After watching this once, I understand the mathematics behind neural networks and why the functions are used. Great job with the explanation here. Many thanks.

  • @alperengul8654
    @alperengul8654 3 ปีที่แล้ว +2341

    If you make more deep learning videos with numpy and math(without any framework) just like in this video, it would be great for begginers to learn basics!!! Do you think to keep continue??

    • @cemsalta
      @cemsalta 3 ปีที่แล้ว +12

      Merhaba Eren!

    • @kanui3618
      @kanui3618 3 ปีที่แล้ว +1

      upp!

    • @anishojha1020
      @anishojha1020 3 ปีที่แล้ว +3

      Hey guys, a reply would be highly appreciated. I want to plot the cost vs the number of iterations but I am not able to figure which parameter to plot ? I am a beginner and I would really appreciate the help. Thank you

    • @KHM95
      @KHM95 3 ปีที่แล้ว

      Here's a course you'll need.
      Face Mask Detection Using Deep Learning and Neural Networks. It's paid but it's worth it.
      khadymschool.thinkific.com/courses/data-science-hands-on-covid-19-face-mask-detection-cnn-open-cv

    • @w花b
      @w花b 2 ปีที่แล้ว +16

      @@anishojha1020 you're probably not a beginner anymore so I hope you found your answer! Unfortunately, youtube comment section isn't a forum and a lot of people disable notifications(including me) so an actual forum although people are sometimes really rude and condescending, is your best bet for future questions.

  • @TimeRoot
    @TimeRoot 2 ปีที่แล้ว +784

    00:51 Problem statement
    01:18 Math explanation
    11:18 Coding it up
    27:43 Result's

  • @luisbq8045
    @luisbq8045 ปีที่แล้ว +41

    This is pure gold, MSc in Data Science and Artificial Intelligence, no professor ever gave me the answer to "what is the code inside the libraries we use", until I found you. Thank you

    • @rushisy
      @rushisy ปีที่แล้ว +14

      thats sad

    • @stanislavlia
      @stanislavlia ปีที่แล้ว

      I don't want to sound too catchy and annoying but the NN's in Tensorflow and PyTorch are not actually implemented like this. They don't store functions to compute gradients for every single option rather they use AutoGradient which does all backpropogation job. I would highly recommend to watch Andrej Karpathy's tutorial on micrograd (mini AutoGradient which you will implement)

    • @michaelpieters1844
      @michaelpieters1844 8 หลายเดือนก่อน +5

      I got a master in physics and statistics but I do know how to code a lot of "machine learning" techniques from scratch. Yet human resources look at my degree and think I am incapable, so they rather hire master in AI. I can also code CFD, SPH and FEA from scratch but HR say I am dumber than engineer who just uses third party software (ansys).

    • @suscactus420
      @suscactus420 7 หลายเดือนก่อน

      @@michaelpieters1844 welcome to recruitment in 2024... you need to feed the recruiters what they want to hear, so that you can then get to the guy who you actually want to talk to about your stuff.

    • @Iqbal00123
      @Iqbal00123 5 หลายเดือนก่อน

      @@michaelpieters1844 You are dumb compared to a ML engineer.Masters in Physics is far too easy

  • @LydellAaron
    @LydellAaron 2 ปีที่แล้ว +22

    Just your intro alone in your motivations was so capturing. You laid out everything so clearly, including creating those row and column matrices in the early steps. Thank you.

  • @mdgsteeplejack4711
    @mdgsteeplejack4711 3 หลายเดือนก่อน +3

    I am so glad, that whenever some teacher just skips the tricky part, a friendly+capable asian guy jumps out of nowhere to casually explain higher math in depth to you.

  • @omlachake2551
    @omlachake2551 3 ปีที่แล้ว +111

    this type of learning is honestly the best, i implemented k means clustering by myself in c (pretty easy stuff but still) , and i can never forget it now, makes me happy that i can do stuff too

    • @Emily-fm7pt
      @Emily-fm7pt 2 ปีที่แล้ว +21

      When I was in high-school algebra I programmed an algebra calculator to do my homework for me, and for some reason I never actually needed it. Programming something really is a great way of learning it, even if it does take significantly longer than just some p-sets or flashcards.

    • @OT-tn7ci
      @OT-tn7ci 2 ปีที่แล้ว +1

      @@Emily-fm7pt dude are you serious ??? SAME SAME lmao

    • @auronusben4567
      @auronusben4567 ปีที่แล้ว +6

      I remember when I tried to implement a decision tree on paper !! With a very small data dimensions (maybe 5x6 dim? Can't remember). I spent all the night doing the math but after 5-6 hours I realized I made a mistake in an iteration 😂😂 that's when I realized that we're lucky to have computers to help do it because a human mind can't build completely without doing mistakes in the process (can't stay focus for long time)...
      I also remember when I implemented a PCA from scratch on excel ( still have the Excel 😂)...😮

  • @llewsub
    @llewsub ปีที่แล้ว +7

    Most tutorials I watch online about ML, you can just tell that the instructor doens't know whats happening. They've just memorized libraries and tensorflow syntax, and I don't want that to be me! This is exactly what i've been looking for! THANK YOU!!!

  • @randyscorner9434
    @randyscorner9434 8 หลายเดือนก่อน +1

    Excellent tutorial and example. Reveals the magic that most don't know about NNs and I love how you go about it.

  • @mauricioledon4498
    @mauricioledon4498 2 ปีที่แล้ว +4

    You sir, are my hero. You are the first person to actually explain this properly to me. Thank you so much for that.

  • @solleo9
    @solleo9 2 ปีที่แล้ว +10

    What an impressive speed run! Just nitpicking: 15:45 `rand` is for a uniform dist U(0,1) and `randn` is for the standard normal distribution N(0,1), therefore unbounded, not U(-0.5, 0.5)

  • @notyou4122
    @notyou4122 2 ปีที่แล้ว +16

    Musician, filmmaker, data scientist, and etc. bro maxed out on skill trees. 😂

  • @edisonbekaj863
    @edisonbekaj863 2 ปีที่แล้ว

    Samson Zhang is the BEST Cinematographer, editor, musician& tech geek in the WORLD

  • @numberiforgot
    @numberiforgot 2 ปีที่แล้ว +3

    I love it when I learn more from a YT video than my computer science courses.

  • @David-ip2sd
    @David-ip2sd ปีที่แล้ว +59

    Hi! I did a recreation of your code with more hidden layers and noticed what I think is a bug in the db calculation. Changing it to db = 1 / m * np.sum(dZ, axis=1).reshape(-1, 1) was able to get me better results. I think the old db = 1 / m * np.sum(dZ) sums the entire dZ to one float. Very good video though!

    • @Hyngvi
      @Hyngvi ปีที่แล้ว +1

      noticed the same thing. The way it was implemented here returns db to a float and thus b will always be "similar" to the random initialization, only shifted up/down by a constant.

    • @matthewjouffray
      @matthewjouffray ปีที่แล้ว

      Hey, I know you posted this a while ago, but I noticed the same thing and saw your comment. I am still not sure how to solve this, dZ is still a 1D array (1 by 10) so in your solution, what does axis=1 do? won't .sum*() just turn the 1D array into a scalar regardless, and then you are back with the same problem of updating all your biases the same way?

    • @matthewjouffray
      @matthewjouffray ปีที่แล้ว

      Actually, nevermind, dZ is 10 by m so this does make sense

    • @gpeschke
      @gpeschke 10 หลายเดือนก่อน +2

      Numpy requires some strange things when you have only 1 dimension:
      Verfied that without this change the final biases weights aren't being updated.
      With it, training works better. Didn't verify the details of David's solution, just that it was needed, and that it seemed to work.
      def backward_prop(Z1, A1, Z2, A2, W1, W2, X, Y):
      one_hot_Y = one_hot(Y)
      dZ2 = A2 - one_hot_Y
      dW2 = 1 / m * dZ2.dot(A1.T)
      db2 = 1 / m * np.sum(dZ2, axis=1).reshape(-1, 1)
      dZ1 = W2.T.dot(dZ2) * ReLU_deriv(Z1)
      dW1 = 1 / m * dZ1.dot(X.T)
      db1 = 1 / m * np.sum(dZ1, axis=1).reshape(-1, 1)
      return dW1, db1, dW2, db2

    • @danielmyers76
      @danielmyers76 6 หลายเดือนก่อน

      I see the same. Also, either this is old enough that something has changed in Python or numpy, or he hasn’t included other things as well. Using his code line for line and the same data set, I get a divide by zero error on the softmax function.

  • @iwasdeleted708
    @iwasdeleted708 ปีที่แล้ว +2

    the fact he actually shows the first overconfident of its memory programer stage is actually so real.

  • @JustKevStockholm
    @JustKevStockholm ปีที่แล้ว +30

    Hi Samson! I'm a developer and trying to learn the basics of ML. Much of the beginner stuff I see is using pre-trained models and frameworks which might be convenient to get things going. However, for me this is something completely new and I really what to understand what happens behind the scenes. Thank you for posting this! /Kevin from Sweden

    • @paultvshow
      @paultvshow 10 หลายเดือนก่อน +1

      ⁠Exactly!

    • @carnap355
      @carnap355 9 หลายเดือนก่อน

      try jeremy howard part2 of 2022 courses

  • @ItsNaberius
    @ItsNaberius 7 หลายเดือนก่อน

    Really excellent breakdown of a Neural Network, especially the math explanation in the beginning. I also want to say how much I appreciate you leaving in your first attempt at coding it and the mistakes you made. Coding is hard, and spending an hour debugging your code just because of one little number is so real. Great video

  • @Bobbleheads56
    @Bobbleheads56 2 ปีที่แล้ว +5

    I need to come back to this after learning some more preliminaries but you are a very natural teacher and good at presenting. Keep it up 👍

  • @letticonionepic
    @letticonionepic ปีที่แล้ว

    I know the Maths and Programming behind it and listening this guy doing all that on his own is pure respect from my side.

  • @Hex...
    @Hex... ปีที่แล้ว +23

    This was interesting, it certainly made neural networks far more approachable to me as someone who's never needed to/been inclined to try making one, but encounters them frequently by being involved in STEM. Your explanations coupled with my familiarity with numpy as opposed to dedicated libraries for neural networks really helped - thanks!

  • @hassaannoor
    @hassaannoor 3 ปีที่แล้ว +2

    Thanks so much for providing the notebook. I tested with different learning rates and lo and behold, 0.50 gives 91% accuracy on test data. And by setting the number of neurons in the deep layer to 20. The accuracy of 93% was achieved.

    • @nithinsai2250
      @nithinsai2250 3 ปีที่แล้ว +1

      try changing the epoch too

    • @hassaannoor
      @hassaannoor 3 ปีที่แล้ว

      @@nithinsai2250 Yeah I tried 1000, it did improve it. But I wanted to benchmark the inference against the same epochs.

    • @KHM95
      @KHM95 3 ปีที่แล้ว

      Here's a course you'll need.
      Face Mask Detection Using Deep Learning and Neural Networks. It's paid but it's worth it.
      khadymschool.thinkific.com/courses/data-science-hands-on-covid-19-face-mask-detection-cnn-open-cv

  • @GrahamEckel
    @GrahamEckel ปีที่แล้ว +4

    Better lecture and example for understanding and building NN than any in my math and stats MSc

  • @leonhardlischka221
    @leonhardlischka221 6 หลายเดือนก่อน

    I had many Machine Learning seminars in University and saw a lot of videos online on this topic. This is definitelly one of the best i ever saw. All relevant information in such short time, explained with such a high didactic quality. Wish i've had such docents at University. You should go teaching in MIT.

  • @123arskas
    @123arskas 2 ปีที่แล้ว +4

    Just 1 minute in the video and I can easily tell that you're gonna own a multi-billion company within a few years. You've got the IQ, the voice, the clarity, the confidence, and the right personality. Best of luck Mr. Zhang

  • @DungeonMasterpiece
    @DungeonMasterpiece 2 ปีที่แล้ว +2

    I've been looking for this video for 6 years.

  • @Crayphor
    @Crayphor ปีที่แล้ว +11

    It's worth noting that softmax IS actually very similar to sigmoid. But it essentially does a sigmoid over multiple classes.

  • @dcrespin
    @dcrespin ปีที่แล้ว +5

    An excellent nice video with abundant mathematical insight.
    It may be worth to note that instead of partial derivatives one can work with derivatives as the linear transformations they really are, and also looking at the networks in a more structured manner thus making clear how the basic ideas of BPP apply to much more general cases. Several steps are involved.
    1.- More general processing units.
    Any continuously differentiable function of inputs and weights will do; these inputs and weights can belong, beyond Euclidean spaces, to any Hilbert space. Derivatives are linear transformations and the derivative of a neural processing unit is the direct sum of its partial derivatives with respect to the inputs and with respect to the weights; this is a linear transformation expressed as the sum of its restrictions to a pair of complementary subspaces.
    2.- More general layers (any number of units).
    Single unit layers can create a bottleneck that renders the whole network useless. Putting together several units in a unique layer is equivalent to taking their product (as functions, in the sense of set theory). The layers are functions of the of inputs and of the weights of the totality of the units. The derivative of a layer is then the product of the derivatives of the units; this is a product of linear transformations.
    3.- Networks with any number of layers.
    A network is the composition (as functions, and in the set theoretical sense) of its layers. By the chain rule the derivative of the network is the composition of the derivatives of the layers; this is a composition of linear transformations.
    4.- Quadratic error of a function.
    ...
    ---
    Since this comment is becoming too long I will stop here. The point is that a very general viewpoint clarifies many aspects of BPP.
    If you are interested in the full story and have some familiarity with Hilbert spaces please google for papers dealing with backpropagation in Hilbert spaces. A related article with matrix formulas for backpropagation on semilinear networks is also available.
    For a glimpse into a completely new deep learning algorithm which is orders of magnitude more efficient, controllable and faster than BPP search in this platform for a video about deep learning without backpropagation; in its description there are links to a demo software.
    The new algorithm is based on the following very general and powerful result (google it): Polyhedrons and perceptrons are functionally equivalent.
    For the elementary conceptual basis of NNs see the article Neural Network Formalism.
    Daniel Crespin

  • @jamescardenas837
    @jamescardenas837 7 หลายเดือนก่อน

    i have no idea what your were really saying but at the same time i do because you explained how the math is used and implemented for the code. thank you !

  • @robertknopf6207
    @robertknopf6207 3 ปีที่แล้ว +20

    Another thing that would be helpful for those of us that want to copy what you did and experiment with it is to have all the code together instead of separated as it is using Kaggle - this way you can put in some comments with the code explaining the different features. Again, very good video.

  • @momol.9892
    @momol.9892 6 หลายเดือนก่อน

    Just learned basics around the neural networks and saw this video. So satisfied to all the math formulas are laid out clearly in numpy and real-world coding and training neural network with back propagation. It really helps beginners like me. Thank you so much!

  • @FireNLightnin
    @FireNLightnin 2 ปีที่แล้ว +9

    Great video! I did the same thing in python about a year ago, but I didn’t like relying on numpy so much. Your video gave me the motivation to write both a matrix manipulator and neural network from scratch in Java

  • @doctorshadow2482
    @doctorshadow2482 7 หลายเดือนก่อน +2

    Good start. Some points:
    1. The article on the link in summary is no more available.
    2. It would be nice to pay more attention to backpropagation, since it is tricky; just a simple question how to choose between adjusting bias and weight?
    3. It would be nice to compare this NN with a simple checking against average "blurred" weighted maps for all numbers on pictures; just blur all 1's, blur separately all 2'th and then compare cosine distance. If the results would be the same as with the NN, the question would be about the Occam's Razor.

    • @Agorith_
      @Agorith_ 7 หลายเดือนก่อน +1

      You can just use the wayback machine since its 3 years old vid.

    • @doctorshadow2482
      @doctorshadow2482 7 หลายเดือนก่อน

      @@Agorith_ б, how is it related to my post?

    • @Agorith_
      @Agorith_ 7 หลายเดือนก่อน

      @@doctorshadow2482 umm I said it for your first point-"The article on the link in summary is no more available."

    • @doctorshadow2482
      @doctorshadow2482 7 หลายเดือนก่อน

      @@Agorith_ , so what? I just giving the update tho the author so that he could update the description or bring back the materials. It is not a complain, just a feedback.

    • @Agorith_
      @Agorith_ 7 หลายเดือนก่อน

      @@doctorshadow2482 I am just making awareness to people who look your comment on where to look and which year to look into.

  • @KSATica
    @KSATica ปีที่แล้ว +23

    You should continue making video similar to this maybe something a training course for machine learning and reinforcement learning AI. You have a real talent for explaining it in the best way possible then from what most videos I’d watched. 👍

  • @arksodyssey
    @arksodyssey 9 หลายเดือนก่อน +1

    This solved a lot of doubts and brought up mu confidence levels to deep dive into AI/ML. Thanks for the explanation.

  • @jeandy4495
    @jeandy4495 2 ปีที่แล้ว +6

    Super cool! Would also recommend the series from The Coding Train about creating a neural network from scratch, going a little more into the details of math and what is a perceptron and so.

  • @peterweicker77
    @peterweicker77 11 หลายเดือนก่อน

    This is great. Built a backprop in C thirty years ago to solve the same problem. Just for a goof. It worked well before I finished debugging.
    These things are awesome and now I want to take another look. Thanks for posting this.

  • @Mutual_Information
    @Mutual_Information 2 ปีที่แล้ว +9

    Just discovered this channel. Very cool stuff. Much respect for doing something challenging like this.

  • @anandptyagi5275
    @anandptyagi5275 2 ปีที่แล้ว +2

    After Andrew Ng's course, this is the first time I'm watching math functions, thanks buddy, it was a nice refresher for me.

  • @darrellrayford3817
    @darrellrayford3817 2 ปีที่แล้ว +19

    This was a really good video. I’ve never build a neural network but it was interesting seeing how the fundamentals add up to build something a little more complexed.

  • @blueblackcloud
    @blueblackcloud 5 หลายเดือนก่อน

    you got a face of child but wisdom and heart of a man! Love the video

  • @aaliyahiam4286
    @aaliyahiam4286 2 ปีที่แล้ว +3

    this man appeared, released an absolute banger of a programming video, and proceeded to never posted any cs content again. sigma mentality tbh

  • @hocm2
    @hocm2 6 หลายเดือนก่อน

    Maaan, I am so happy you made this video. I was looking for somebody to train the Neural Network from scratch. I will go through it several times to get into the subject. Your English is excellent! Many, many thanks!

  • @sharmakartikeya
    @sharmakartikeya 3 ปีที่แล้ว +21

    Bro, that is exactly how I study! I found out your channel and I am so glad I did. Instantly subscribed!
    I see you have learnt from Andrew Ng

    • @rishikeshkanabar4650
      @rishikeshkanabar4650 3 ปีที่แล้ว +2

      yeah the notations reminded me of Andrew Ng

    • @kumaranp8764
      @kumaranp8764 3 ปีที่แล้ว +4

      @@rishikeshkanabar4650 usage of the word called "intuition" reminds me of him saying ..."to get a better intuition" in his lectures

  • @CristianMorales-zo1jb
    @CristianMorales-zo1jb ปีที่แล้ว +4

    Subscribed at 0:05 seconds because you look smart AF kid. Thanks for teaching.

    • @AvinashKJ
      @AvinashKJ 3 หลายเดือนก่อน

      Smart 😂😂

  • @andimuhammadryanto9295
    @andimuhammadryanto9295 ปีที่แล้ว

    bro, I am watching NN course from online platform for 1 months, but still difficult to get grasp on it. But you made me understand it in just 30 mins. many thanks

  • @lbb2rfarangkiinok
    @lbb2rfarangkiinok 2 ปีที่แล้ว +4

    This was really neat. The math explanation was frustrating the first time around but really made sense after working through the code. Thanks for sharing.

  • @Scott_in_LA
    @Scott_in_LA 10 วันที่ผ่านมา

    VERY helpful! I could never understand the weightings when I watched (lots and lots) of other videos, but this did it for me - I get it now (as much as I am capable of!). Thanks again!!

  • @kamaldani1686
    @kamaldani1686 7 หลายเดือนก่อน +18

    Understood nothing but wow

  • @gnorts_mr_alien
    @gnorts_mr_alien 2 ปีที่แล้ว +1

    This is the first ASMR NN video that I have ever seen. Well done.

  • @minjunkevink
    @minjunkevink 2 ปีที่แล้ว +3

    Amazing. Needed to see the low end and finally found it. Thank you for the amazing video!

  • @webgpu
    @webgpu 4 หลายเดือนก่อน

    Samson, i am extremelly sarcastic and devastatingly critical when i make comments, but i have to give you kudos for having the brightest idea i've seen , to just split the screen between the content and yourself, i really liked your idea, everyone should do this. 👍

    • @webgpu
      @webgpu 4 หลายเดือนก่อน

      (as for the content of your video, so far (@7min), i've found it really good also, so i'm just adding it to my AI playlist, when i finish watching it i'll probally subscribe)

  • @juliocardoza6066
    @juliocardoza6066 2 ปีที่แล้ว +5

    Samson, Keep doing this kind of videos please!! Very intelligent and understandable video

  • @Felix14325
    @Felix14325 ปีที่แล้ว

    Amazing video for beginners to gain an insight in how neural networks work. You just have to have programmed a simple neural net from scratch once to have a good basic understanding.

  • @ricardo5875
    @ricardo5875 3 ปีที่แล้ว +16

    This is a great way to teach ANN - congrats. However, I would like to suggest you to not worry too much about the time to finish the implementation. Double-checking all steps will avoid coding errors.

  • @aronpop1447
    @aronpop1447 2 ปีที่แล้ว +1

    finally someone who actually respects the craft

  • @SnackPack913
    @SnackPack913 ปีที่แล้ว +8

    I’m always too intimidated to try some of these things. But seeing your process makes it really seem feasible. Need to brush up on my linear algebra again tho 😆

  • @aureliencobb199
    @aureliencobb199 ปีที่แล้ว

    Brilliant. Kind of the Hello World of neural nets. It shed a lot of light for me on how back propagation works.

  • @f.osborn1579
    @f.osborn1579 2 ปีที่แล้ว +7

    Haven’t finished video yet, but this looks like the missing piece of my experience learning about neural networks at a high level…I probably lacked the linear algebra skills I have now though. Whoa! This could be incredibly exciting! I can’t wait!

    • @mrgenetics4063
      @mrgenetics4063 2 ปีที่แล้ว

      Nobody cares what you have to say

  • @mohamedgrich1368
    @mohamedgrich1368 ปีที่แล้ว

    Am I the only one who sees Andrew Ng Junior? Good work man! Keep it up!

  • @RonClabo
    @RonClabo 3 ปีที่แล้ว +12

    What an awesome video! Thank you for sharing this insightful walkthrough, it was really helpful in getting a better understanding of how neural nets works. Thank you!

    • @KHM95
      @KHM95 3 ปีที่แล้ว

      Here's a course you'll need.
      Face Mask Detection Using Deep Learning and Neural Networks. It's paid but it's worth it.
      khadymschool.thinkific.com/courses/data-science-hands-on-covid-19-face-mask-detection-cnn-open-cv

  • @eliporter3980
    @eliporter3980 8 หลายเดือนก่อน

    About a week ago I started giving myself a machine learning crash course and I'm surprised to say I'm starting to understand this stuff. It's not as complicated as I thought.

  • @tommyhuffman7499
    @tommyhuffman7499 ปีที่แล้ว +6

    It's a shame it isn't taught this way in courses. Excellent video!

  • @LeicaM11
    @LeicaM11 2 ปีที่แล้ว

    I have learned this back in 1988, when visiting lectures by Prof. Rechenberg at Technical University. So inspiring. Today I am trying this with my new M1 max and its neural network😝😝

  • @Kaetemi
    @Kaetemi ปีที่แล้ว +6

    Helpful, thanks. Made my own from scratch in bare C++. From image to 32 to 16 to 10 outputs, using leaky ReLU. 96% accuracy on the test set. 🥳

  • @sanglar3623
    @sanglar3623 2 ปีที่แล้ว

    The yt algorithm only recommends me this now, 1 year after i've encountered a similar discontent with neural network tutorials. Still very interresting to see how someone else does it. I did give myself a bit of help by using a library called Eigen for the matrixes calculations.
    Very well done nice video

  • @FreakyStyleytobby
    @FreakyStyleytobby 2 ปีที่แล้ว +10

    Man this video is a masterpiece. I learned a lot and I love your thorough, calm style. Please keep doing similar content!! Best wishes

  • @carloscortes2391
    @carloscortes2391 11 หลายเดือนก่อน

    I am going to do the same over the next two weeks , at the end I'm coming back to see any differences between our code, thanks for sharing :)

  • @faris.abuali
    @faris.abuali 2 ปีที่แล้ว +4

    Thank you so much Mr. Samson!!
    This was so informative and enlightening

  • @lazyraccoon5516
    @lazyraccoon5516 ปีที่แล้ว

    would love to watch this but after the first 5 minutes I realized I have not reached this kind of level of math so see you in 3 years :)

  • @DanIel-fl1vc
    @DanIel-fl1vc 2 ปีที่แล้ว +11

    I've found that educators EVERYWHERE make things more complicated than they really are. The attitude goes something like this, if I explained it so a toddler could understand it. (Which they're capable of doing) I would be out of a job or people would think less of me. True of people talking about music, true of programming and of portrait painting as well. None of this is complicated, just explained poorly or not at all. Number one rule of educator, don't assume the student knows what you're talking about.

    • @doords
      @doords 2 ปีที่แล้ว

      I see people in youtube videos just types for 5 minutes without saying a thing or suddenly start to rewrite things.

    • @abashimov
      @abashimov 2 ปีที่แล้ว

      Spot on

    • @DanIel-fl1vc
      @DanIel-fl1vc 2 ปีที่แล้ว +1

      @@doords What, I've been through the grind I know what I'm talking about.
      Music theory in particular is more than any other discipline guilty of this, programming to a lesser extent. There's a community of underachievers that need to boost their ego by making it seem harder than it is.
      Usually by using made up lingo instead of two words everyone are familiar with, or made up quirky symbols instead of something that visually makes sense to everyone.
      What could be explained in 20 minutes takes 3 years to "teach". It does annoy me, fragile egos that need to prove themselves and hammer down at anyone that doesn't suck up to their sense of...moral superiority or superiority in any way.
      If you want to teach something, stop messing about damn soy boy.

    • @MrCmon113
      @MrCmon113 ปีที่แล้ว

      It is more complicated if it's supposed to work with arbitrary amounts of layers.
      But yeah I think coding up something like this can be very helpful, because it shows you what information is actually available and typically not used by practitioners. You don't just have the gradients of batch-averages of losses - you have much more.

    • @JitendraYadav-w6d8c
      @JitendraYadav-w6d8c 7 หลายเดือนก่อน +1

      Skill issue

  • @Array_of_objects
    @Array_of_objects ปีที่แล้ว

    Your Notes are exceptionally written. Leonardo Davinci did that. Some of the smartest people take beautiful notes. coorelation

  • @AAAJ27
    @AAAJ27 2 ปีที่แล้ว +4

    Samson, this was such a great walk through. Just wanted to say that if you ever made other videos recreating machine learning models from scratch, I'd 100% watch them. In any case, hope all is good and thanks for this great content :)

  • @Jayveersinh_Raj
    @Jayveersinh_Raj 2 ปีที่แล้ว

    I really am like you, as you said you learn better when you dive deep into the scratch with equations you understand better. But, now I think that's the case with most of the people.

  • @cbeezy4733
    @cbeezy4733 2 ปีที่แล้ว +3

    Perhaps I overcomplicated matters compared to your approach when I did this a couple of years ago, but like you, I wanted to program it "from scratch". My language of choice: java. I actually simulated "neurons" which were a class that stored its activation data value, and its connections to the next layer, so that it "looked" like a K_m,n graph, and the connection was an array which stored the biases along each "synapse" so to speak. Then when the hidden layers activated, I had each neuron simply sum the outputs from each synapse connecting to it from the previous layer, which was just the product of its activation value and its bias, then sigmoided this to get its own activation value. Note that while each neuron's activation was only in (-1,1), I let the biases be free parameters. When I programmed the backprop algo, I did the gradient descent the same as you, but effectively set that alpha parameter to one. It didn't occur to me to mess with that. Starting the network out with random parameters, then training it on randomly chosen sets of 10,000 images five or six times seemed to work pretty well. I saw 93% accuracy on the test data.
    And just for fun, I put the network on a discord bot so my friends could feed it images of the same size and see its guess. Two interesting results came out. The network fails on inverted colors: i.e., drawing white on black using MS paint or something wouldn't get reliable predictions. Secondly, using MS paint to give it new data did work, but at a much lower rate. Our best guess for why this happened was due to the sharpness of the lines between the number and backgrounds.

  • @bjornnorenjobb
    @bjornnorenjobb 3 ปีที่แล้ว +1

    this video deserves at least 1 million views

  • @GiacomoMiola
    @GiacomoMiola 2 ปีที่แล้ว +9

    It's a MLP, you easily computed the backpropagation step in closed form, but I wonder how those famous frameworks can compute any network's partial-derivatives tensors automatically

    • @elliott614
      @elliott614 2 ปีที่แล้ว +1

      usually the partial derivatives in backpropagation are of functions specifically chosen to be convex and have nothing to do with the problem you are working on, but are just ones that work nicely for ML algos

  • @rodakdev
    @rodakdev 3 ปีที่แล้ว

    No other video about neural networks can explain neural networks better than this one

    • @anishojha1020
      @anishojha1020 3 ปีที่แล้ว

      Hey guys, a reply would be highly appreciated. I want to plot the cost vs the number of iterations but I am not able to figure which parameter to plot ? I am a beginner and I would really appreciate the help. Thank you

  • @work9466
    @work9466 2 ปีที่แล้ว +4

    I actually did this exact same thing for my German a level project. Same database. :D good times

  • @derpythecate6842
    @derpythecate6842 8 หลายเดือนก่อน +2

    The most sadistic thing I've made for a school project was a multi layer perceptron in C. No stdlibs either. Just raw hard math, all functions were approximated where possible e.g sigmoid, multiplication since it wasn't available.
    The only part I couldn't make was to generate randomness in initial weights which is important to ensure neurons train assymetrically.
    It was all so it would run on a custom RISC V processor (which the multiply, or M extension was sometimes unavailable). My proudest and most depressing creation.

  • @mercedeszkistoth5367
    @mercedeszkistoth5367 2 ปีที่แล้ว +14

    There is one thing I do not understand. Because the derivation and chain rule stuff, shouldn't the derivative of the softmax activation function also be included somewhere?

  • @straightup7up
    @straightup7up ปีที่แล้ว +1

    Samson, we need more videos like this from you. Great content, more visuals would be nice, too 🙂

  • @isreallealbertsanchez1156
    @isreallealbertsanchez1156 3 ปีที่แล้ว +31

    Timestaps if you forgot
    0:51 Problem Statement
    1:18 Math Explanation
    11:18 Coding It up
    27:43 Results

    • @KHM95
      @KHM95 3 ปีที่แล้ว

      Here's a course you'll need.
      Face Mask Detection Using Deep Learning and Neural Networks. It's paid but it's worth it.
      khadymschool.thinkific.com/courses/data-science-hands-on-covid-19-face-mask-detection-cnn-open-cv

    • @Achrononmaster
      @Achrononmaster 2 ปีที่แล้ว +1

      @18:07 is the time stamp where the other error was made, a2 = softmax(a1) which should be
      a2 = softmax(z2)

    • @Achrononmaster
      @Achrononmaster 2 ปีที่แล้ว +1

      @23:30 you also see two errors, there is no axis argument for the np.sum(), the lines should be
      db2 = 1 / m * np.sum(dZ2) ... and ... db1 = 1 / m * np.sum(dZ1)

    • @Achrononmaster
      @Achrononmaster 2 ปีที่แล้ว +1

      And @23:00 ReLU_deriv(z) should really be return np.array(zn > 0, dtype=float) if you are aiming for good typing practice.

    • @elivelive
      @elivelive 2 ปีที่แล้ว

      I don't understand anything but wow

  • @joschkazimdars
    @joschkazimdars 3 ปีที่แล้ว

    It feels like it took me months to understand programming feedforward neural networks but I finally understand it. Thanks for the video.

  • @themoonlight1922
    @themoonlight1922 3 ปีที่แล้ว +19

    Hi, i found this video very helpful for beginners. Could you please tell how you came up the equations of dz,dw and db? That would be really helpful as well

    • @aryamankukal1056
      @aryamankukal1056 2 ปีที่แล้ว +2

      watch andrew ng he copied every single equation from his course

    • @Beyond_b1
      @Beyond_b1 ปีที่แล้ว +2

      @@aryamankukal1056 I wouldn’t say he copied every equation. These equations are taught in all ML/AI courses and it is just mathematics

    • @aryamankukal1056
      @aryamankukal1056 ปีที่แล้ว +1

      @@Beyond_b1 andrew's notation is a very specific and if u watch carefully he uses all of the same conventions

  • @Patrick-wn6uj
    @Patrick-wn6uj 9 หลายเดือนก่อน +1

    Its crazy how i understand this now, years ago i didn't know what was going on. when I watched this video

  • @chessprogramming591
    @chessprogramming591 2 ปีที่แล้ว +3

    Thank you for your time and effort, Samson, this tutorial is a treasure.

  • @georgeseese
    @georgeseese 10 หลายเดือนก่อน

    Readers should not expect the code to work and nobody has the time to explain why it doesn't work. There are differences between the code in this video and the code in your kaggle notebook. However, thanks for showing the basic workflow! I hope this will help us understand software like TensorFlow.

  • @harisjaved1379
    @harisjaved1379 2 ปีที่แล้ว +4

    I agree with you. I also did this by scratch. It was a lot of fun! What’s the point of masters math degree if I am not going to use it lol. Nice work!

    • @Pk-tw6li
      @Pk-tw6li 2 ปีที่แล้ว

      bro can you help i also wanna learn can you tell us resources which you use to learn this neural network

    • @juliopaniagua8723
      @juliopaniagua8723 2 ปีที่แล้ว

      @@Pk-tw6li study some basic linear algebra, just with that you'll understand at least 85% of whats going on with the algorithm

  • @kurtameyer
    @kurtameyer 9 หลายเดือนก่อน

    Thank you. I'm doing this in class right now and your explanations were super helpful!

  • @Milorae
    @Milorae 2 ปีที่แล้ว +3

    Everyone praises this video for being so helpful and I'm just sitting here understanding NOTHING. :D I feel so dumb! Maybe I should've stared with something even more basic having learned in a nutshell only print("hello world") so far. I will definitely go back and watch it all again in the future after I learn more. Thank you for the video, Samson. Cheers!

    • @xianzai_ad1928
      @xianzai_ad1928 2 ปีที่แล้ว +1

      defintely pick up a book on algorithims and data structures first!