This is a three. It’s sloppily written and rendered at an extremely low resolution of 28 by 28 pixels. But your brain has no trouble recognizing it as a three and I want you to take a moment to appreciate How crazy it is that brains can do this so effortlessly? I mean this this and this are also recognizable as threes, even though the specific values of each pixel is very different from one image to the next. The particular light-sensitive cells in your eye that are firing when you see this three are very different from the ones firing when you see this three. But something in that crazy smart visual cortex of yours resolves these as representing the same idea while at the same time recognizing other images as their own distinct ideas But if I told you hey sit down and write for me a program that takes in a grid of 28 by 28 pixels like this and outputs a single number between 0 and 10 telling you what it thinks the digit is Well the task goes from comically trivial to dauntingly difficult Unless you’ve been living under a rock I think I hardly need to motivate the relevance and importance of machine learning and neural networks to the present into the future But what I want to do here is show you what a neural network actually is Assuming no background and to help visualize what it’s doing not as a buzzword but as a piece of math My hope is just that you come away feeling like this structure itself is Motivated and to feel like you know what it means when you read or you hear about a neural network quote-unquote learning This video is just going to be devoted to the structure component of that and the following one is going to tackle learning What we’re going to do is put together a neural network that can learn to recognize handwritten digits This is a somewhat classic example for Introducing the topic and I’m happy to stick with the status quo here because at the end of the two videos I want to point You to a couple good resources where you can learn more and where you can download the code that does this and play with it? on your own computer There are many many variants of neural networks and in recent years There’s been sort of a boom in research towards these variants But in these two introductory videos you and I are just going to look at the simplest plain-vanilla form with no added frills This is kind of a necessary prerequisite for understanding any of the more powerful modern variants and Trust me it still has plenty of complexity for us to wrap our minds around But even in this simplest form it can learn to recognize handwritten digits Which is a pretty cool thing for a computer to be able to do. And at the same time you’ll see how it does fall short of a couple hopes that we might have for it As the name suggests neural networks are inspired by the brain, but let’s break that down What are the neurons and in what sense are they linked together? Right now when I say neuron all I want you to think about is a thing that holds a number Specifically a number between 0 & 1 it’s really not more than that For example the network starts with a bunch of neurons corresponding to each of the 28 times 28 pixels of the input image which is 784 neurons in total each one of these holds a number that represents the grayscale value of the corresponding pixel ranging from 0 for black pixels up to 1 for white pixels This number inside the neuron is called its activation and the image you might have in mind here Is that each neuron is lit up when its activation is a high number? So all of these 784 neurons make up the first layer of our network Now jumping over to the last layer this has ten neurons each representing one of the digits the activation in these neurons again some number that’s between zero and one Represents how much the system thinks that a given image? Corresponds with a given digit. There’s also a couple layers in between called the hidden layers Which for the time being? Should just be a giant question mark for how on earth this process of recognizing digits is going to be handled In this network I chose two hidden layers each one with 16 neurons and admittedly that’s kind of an arbitrary choice to be honest I chose two layers based on how I want to motivate the structure in just a moment and 16 well that was just a nice number to fit on the screen in practice There is a lot of room for experiment with a specific structure here The way the network operates activations in one layer determine the activations of the next layer And of course the heart of the network as an information processing mechanism comes down to exactly how those activations from one layer bring about activations in the next layer It’s meant to be loosely analogous to how in biological networks of neurons some groups of neurons firing cause certain others to fire Now the network I’m showing here has already been trained to recognize digits and let me show you what I mean by that It means if you feed in an image lighting up all 784 neurons of the input layer according to the brightness of each pixel in the image That pattern of activations causes some very specific pattern in the next layer Which causes some pattern in the one after it? Which finally gives some pattern in the output layer and? The brightest neuron of that output layer is the network’s choice so to speak for what digit this image represents? And before jumping into the math for how one layer influences the next or how training works? Let’s just talk about why it’s even reasonable to expect a layered structure like this to behave intelligently What are we expecting here? What is the best hope for what those middle layers might be doing? Well when you or I recognize digits we piece together various components a nine has a loop up top and a line on the right an 8 also has a loop up top, but it’s paired with another loop down low A 4 basically breaks down into three specific lines and things like that Now in a perfect world we might hope that each neuron in the second-to-last layer corresponds with one of these sub components That anytime you feed in an image with say a loop up top like a 9 or an 8 There’s some specific Neuron whose activation is going to be close to one and I don’t mean this specific loop of pixels the hope would be that any Generally loopy pattern towards the top sets off this neuron that way going from the third layer to the last one just requires learning which combination of sub components corresponds to which digits Of course that just kicks the problem down the road Because how would you recognize these sub components or even learn what the right sub components should be and I still haven’t even talked about How one layer influences the next but run with me on this one for a moment recognizing a loop can also break down into subproblems One reasonable way to do this would be to first recognize the various little edges that make it up Similarly a long line like the kind you might see in the digits 1 or 4 or 7 Well that’s really just a long edge or maybe you think of it as a certain pattern of several smaller edges So maybe our hope is that each neuron in the second layer of the network corresponds with the various relevant little edges Maybe when an image like this one comes in it lights up all of the neurons associated with around eight to ten specific little edges which in turn lights up the neurons associated with the upper loop and a long vertical line and Those light up the neuron associated with a nine whether or not This is what our final network actually does is another question, one that I’ll come back to once we see how to train the network But this is a hope that we might have. A sort of goal with the layered structure like this Moreover you can imagine how being able to detect edges and patterns like this would be really useful for other image recognition tasks And even beyond image recognition there are all sorts of intelligent things you might want to do that break down into layers of abstraction Parsing speech for example involves taking raw audio and picking out distinct sounds which combine to make certain syllables Which combine to form words which combine to make up phrases and more abstract thoughts etc But getting back to how any of this actually works picture yourself right now designing How exactly the activations in one layer might determine the activations in the next? The goal is to have some mechanism that could conceivably combine pixels into edges Or edges into patterns or patterns into digits and to zoom in on one very specific example Let’s say the hope is for one particular Neuron in the second layer to pick up on whether or not the image has an edge in this region here The question at hand is what parameters should the network have what dials and knobs should you be able to tweak so that it’s expressive enough to potentially capture this pattern or Any other pixel pattern or the pattern that several edges can make a loop and other such things? Well, what we’ll do is assign a weight to each one of the connections between our neuron and the neurons from the first layer These weights are just numbers then take all those activations from the first layer and compute their weighted sum according to these weights I Find it helpful to think of these weights as being organized into a little grid of their own And I’m going to use green pixels to indicate positive weights and red pixels to indicate negative weights Where the brightness of that pixel is some loose depiction of the weights value? Now if we made the weights associated with almost all of the pixels zero except for some positive weights in this region that we care about then taking the weighted sum of all the pixel values really just amounts to adding up the values of the pixel just in the region that we care about And, if you really want it to pick up on whether there’s an edge here what you might do is have some negative weights associated with the surrounding pixels Then the sum is largest when those middle pixels are bright, but the surrounding pixels are darker When you compute a weighted sum like this you might come out with any number but for this network what we want is for activations to be some value between 0 & 1 so a common thing to do is to pump this weighted sum Into some function that squishes the real number line into the range between 0 & 1 and A common function that does this is called the sigmoid function also known as a logistic curve basically very negative inputs end up close to zero very positive inputs end up close to 1 and it just steadily increases around the input 0 So the activation of the neuron here is basically a measure of how positive the relevant weighted sum is But maybe it’s not that you want the neuron to light up when the weighted sum is bigger than 0 Maybe you only want it to be active when the sum is bigger than say 10 That is you want some bias for it to be inactive what we’ll do then is just add in some other number like negative 10 to this weighted sum Before plugging it through the sigmoid squishification function That additional number is called the bias So the weights tell you what pixel pattern this neuron in the second layer is picking up on and the bias tells you how high the weighted sum needs to be before the neuron starts getting meaningfully active And that is just one neuron Every other neuron in this layer is going to be connected to all 784 pixels neurons from the first layer and each one of those 784 connections has its own weight associated with it also each one has some bias some other number that you add on to the weighted sum before squishing it with the sigmoid and That’s a lot to think about with this hidden layer of 16 neurons that’s a total of 784 times 16 weights along with 16 biases And all of that is just the connections from the first layer to the second the connections between the other layers Also, have a bunch of weights and biases associated with them All said and done this network has almost exactly 13,000 total weights and biases 13,000 knobs and dials that can be tweaked and turned to make this network behave in different ways So when we talk about learning? What that’s referring to is getting the computer to find a valid setting for all of these many many numbers so that it’ll actually solve the problem at hand one thought Experiment that is at once fun and kind of horrifying is to imagine sitting down and setting all of these weights and biases by hand Purposefully tweaking the numbers so that the second layer picks up on edges the third layer picks up on patterns etc I personally find this satisfying rather than just reading the network as a total black box Because when the network doesn’t perform the way you anticipate if you’ve built up a little bit of a relationship with what those weights and biases actually mean you have a starting place for Experimenting with how to change the structure to improve or when the network does work? But not for the reasons you might expect Digging into what the weights and biases are doing is a good way to challenge your assumptions and really expose the full space of possible solutions By the way the actual function here is a little cumbersome to write down. Don’t you think? So let me show you a more notationally compact way that these connections are represented. This is how you’d see it If you choose to read up more about neural networks Organize all of the activations from one layer into a column as a vector Then organize all of the weights as a matrix where each row of that matrix corresponds to the connections between one layer and a particular neuron in the next layer What that means is that taking the weighted sum of the activations in the first layer according to these weights? Corresponds to one of the terms in the matrix vector product of everything we have on the left here By the way so much of machine learning just comes down to having a good grasp of linear algebra So for any of you who want a nice visual understanding for matrices and what matrix vector multiplication means take a look at the series I did on linear algebra especially chapter three Back to our expression instead of talking about adding the bias to each one of these values independently we represent it by Organizing all those biases into a vector and adding the entire vector to the previous matrix vector product Then as a final step I’ll rap a sigmoid around the outside here And what that’s supposed to represent is that you’re going to apply the sigmoid function to each specific component of the resulting vector inside So once you write down this weight matrix and these vectors as their own symbols you can communicate the full transition of activations from one layer to the next in an extremely tight and neat little expression and This makes the relevant code both a lot simpler and a lot faster since many libraries optimize the heck out of matrix multiplication Remember how earlier I said these neurons are simply things that hold numbers Well of course the specific numbers that they hold depends on the image you feed in So it’s actually more accurate to think of each neuron as a function one that takes in the outputs of all the neurons in the previous layer and spits out a number between zero and one Really the entire network is just a function one that takes in 784 numbers as an input and spits out ten numbers as an output It’s an absurdly Complicated function one that involves thirteen thousand parameters in the forms of these weights and biases that pick up on certain patterns and which involves iterating many matrix vector products and the sigmoid squish evocation function But it’s just a function nonetheless and in a way it’s kind of reassuring that it looks complicated I mean if it were any simpler what hope would we have that it could take on the challenge of recognizing digits? And how does it take on that challenge? How does this network learn the appropriate weights and biases just by looking at data? Oh? That’s what I’ll show in the next video, and I’ll also dig a little more into what this particular network we are seeing is really doing Now is the point I suppose I should say subscribe to stay notified about when that video or any new videos come out But realistically most of you don’t actually receive notifications from YouTube, do you ? Maybe more honestly I should say subscribe so that the neural networks that underlie YouTube’s Recommendation algorithm are primed to believe that you want to see content from this channel get recommended to you anyway stay posted for more Thank you very much to everyone supporting these videos on patreon I’ve been a little slow to progress in the probability series this summer But I’m jumping back into it after this project so patrons you can look out for updates there To close things off here I have with me Lisha Li Lee who did her PhD work on the theoretical side of deep learning and who currently works at a venture capital firm called amplify partners Who kindly provided some of the funding for this video so Lisha one thing I think we should quickly bring up is this sigmoid function As I understand it early networks used this to squish the relevant weighted sum into that interval between zero and one You know kind of motivated by this biological analogy of neurons either being inactive or active

(Lisha) – Exactly (3B1B) – But relatively few modern networks actually use sigmoid anymore. That’s kind of old school right ?

(Lisha) – Yeah or rather ReLU seems to be much easier to train

(3B1B) – And ReLU really stands for rectified linear unit (Lisha) – Yes it’s this kind of function where you’re just taking a max of 0 and a where a is given by what you were explaining in the video and what this was sort of motivated from I think was a partially by a biological Analogy with how Neurons would either be activated or not and so if it passes a certain threshold It would be the identity function But if it did not then it would just not be activated so be zero so it’s kind of a simplification Using sigmoids didn’t help training, or it was very difficult to train It’s at some point and people just tried relu and it happened to work Very well for these incredibly Deep neural networks.

(3B1B) – All right Thank You Lisha for background amplify partners in early-stage VC invests in technical founders building the next generation of companies focused on the applications of AI if you or someone that you know has ever thought about starting a company someday Or if you’re working on an early-stage one right now the Amplify folks would love to hear from you they even set up a specific email for this video [email protected] so feel free to reach out to them through that

Why Japanese caption is unavailable…!

Finally an explanation for the bias. THANK YOU

Excellent

Thanks.

The only way I am going to love maths is looking at your video… someday could you throw a video on data structures in computers. all the sorting algorithms etc. It would be totally awesome

If I presented to the computer random weights and biases all moving in Rapid multiple random directions and overlapping and changing at high speed while fracturing every time they move I would create a static effect in your computer and scramble it. I can blend my face with a million other faces all moving in different directions and overlapping each other using hologram projection and it would not be able to read my face. What that comes down to is wear clothing with faces all over it and you will confuse the facial recognition. Same thing happens if you do this with numbers letters or symbols. It would not be able to get a read on the target. Similar effect to what camouflage does to the human eye. Train the machine learning on something like a mimic octopus or cuttlefish that are shapeshifters and see what happens.

Or I could hack in to the machine and change the numeric value that is assigned to the shading of the pixelation or the biases and it would confuse the computer because it would change all the math. Sound about right?

so virtual, so good

What i understand was 28×28 is 784

i regret that i have only one subscribe click to give

this video should win oscar.

Я не понял, потому что я тупой.

Too sophisticated. I'm just here to waste time and bandwidth. Haha

But great stuff!!!

There is one person who does it better than Andrew Ng, ladies and gentlemen, Grant Sanderson!

good content

that moment when you realize that a computer has more neurons then u

thank you

fascinating, but jebus i think designing the AI that designs the AI to do this would be simpler

DAMNN BRUH IS BLOWING MY MIND HARD AF

Ditch the background music. It's annoying.

I have loose plans for my future, but if everything goes right..I'll become a psychologist that also codes. Dunno how I can do both of these things, but I'll figure it out.

12:26 :0

보물같은 채널

You explained it so simply, just wow 😮

One of the best things youtube has showed me at 5am 🔥🔥

A neural network brought me here.

Natutoo na sya ng kanya. Parang lobong nabitawan ang tali wala ng control

They ruined all system. They making own command machinen to machine.

One of the best Videos i have come across. Concepts explained so well in layman terms.

한글자막 잘려요 흑흑

Horrifying

Wow… thank you very much sir… I feel so happy watching the video 🙂

Would you make a video on Traffic Modelling?

Correction: 14:48 The bias matrix should be indexed from 0 to k and not 0 to n.

Your channel is amazing, my favourite on youtube.

Do you plan on doing any course on machine learning, data science, or something related?

Thank you so much.

I just picked up "Squeashification" from this video!

Brilliant videos folks. Thanks a ton for the simple explanation of complex topics.

you are talking about cnns lstm better

This video explained neural networks much better than my grad school professor.

By doing things this way, such as that shown for recognizing numbers, aren't we already giving the computer the answers?

For example, when you spoke about a section of the neural net, you showed that it ( The numbers ) gets broken down so that the computer knows what to look for, the circle in the nine, the straight edge of the number nine or one etc.

The computer is then looking for those parts when looking at a number.

At the end of the neural net, it takes the largest number ( Output ) to decide what number it sees.

By putting information is, as to what to look for and compare them, then we are in effect, giving the machine the information to search for.

We as humans, however, have to learn what makes a nine a nine and a six a six because it gets explained to us by outer parents and other adults.

i named my channel black and blue (black was my creativity😂) when i watched your video first time in my high school. sadly i didnt get any grasp what you were telling but felt like oh man i m seeing mathematics. Now i could understand what you were trying to say back then.

Congrats, Notch is one of your Patrons.

a very good tutorial!

In think the Vietsub team may use Google tranlate or they born or lived to long outside VN,because the structure of sentences weren't at right position so I have to read Vietsub, Engsub use google translate and guess. LOL by the way thank for your video! It's a good inspiring video.

Devo dire che e la migliore spiegazione di una rete neurale che io abbia visto. Postane altre ti prego, Grazie mille!

I really don’t know what the fuck I’m watching, but take the like

I was able to hang with you till 10:50 and then my brain popped.

THE TEACHING ASIDE , THOSE GRAPHICS MAN! TAKES LOT OF EFFORT!

How does adding biases increas the number of nodes ?

Awesome video man, that helps me a lot, thanks!

You are a great mentor,sir

Great video

at 14:41, should not bias vector be [b0, b1, … ,bk] instead of [b0, b1, … ,bn] ?

I've recently started learning machine learning and AI and this video is really the best explanation I've ever gotten of how a neural network actually works, thank you so much for this information!

@ 14:18 I was thinking I have seen this formation before then you mentioned linear algebra, and as a matter of fact my lecturer once mentioned that this approach could be used to split signal instead of Fourier transform, using eigen vector or some sort of unitary vector form… This is really a great video just listening to it alone (even if not understanding much of the ideas) is satisfying….

Wow. Most comprehensive and well made video on neural network I've came across.

This video series was very helpful, thank you! But I have a question about the output function. When training for 10 output digits from the inputs, why would there not be at least one more output for 'None of the above'? In other words, why wouldn't I be able to give the neural net the option of saying that the input set doesn't correlate to any of the possible outputs? Wouldn't forcing it to choose one even when none of them make sense cause unnecessary complications in the training and intermediate calculations? Or does providing such an option cause the whole function to collapse because it would 'want' to choose that output almost every time?

Love the format and insights of this video. Maybe I could even use this to explain to non-technical clients the reason I might want to use a neural network for binary classification. I think you cover most of the mathematics behind neural network operation, as you usually do. The only thing I would change is comparing a standard neural network to the biological brain. I would say that it’s more of a closed loop control system. The name ‘neural network’ betrays itself, kind of.

David Hume, an english philosopher said once that our brain can put the missing pieces out of the blue, due to the gradient perception. So, machine learning must work like that, creating that gradient in order to understand what is the last value of a form that can differ a regular number form from another form of the same number and both from a new one.

I just started with machine learning and all this is a little overwhelming….is it just I or everyone feels like that when they start???

Amazing video.. great job!!

Your content is amazing. Please keep it up! 🙂

Is the value -10 as bias arbitrary? What would be the consequence if the bias value is different?

@3Blue1Brown I don't know if I'm getting this wrong or if this has been mentioned already but isn't the bias vector you show at 14:38 supposed to be a k-row by 1 column (k x 1) vector, not an n-row by 1 column (n x 1) vector? The dot product of a (k x n) matrix and a (n x j) matrix is a (k x j) matrix. You would be adding a (k x 1) vector to a (n x 1) vector, which wouldn't work unless n = k.

Nice explanation… thanks

Thanks man. I'm gonna use this in a seminar I will be doing today.

I learned enough mathematical logic/probability theory to implement an entire AI and not a single Neural Network was used. This was hard but rewarding. You can get alot done with just logic and probability haha.

17:33

This is a fanstastic video. Wow. Subscribed!

God blesses you! Great Explanation!

Thank for video, Thank for Vietnamese sub, I love @3Blue1Brown from VietNam

Living things do not recognize or process images in this way. What you have here is nothing but a logic tree. It does not learn. The programmer learns.

NONSENSE !!!

Very good description.

I actually had to watch almost three times to understand the video. But, damn I felt good after understanding. Now that I am taking AI classes at university your videos are like Amrit for me.

Hey Grant! Love your videos!

I was going through this and piecing together the examples myself and I think I found an error in the video. At around 14:46 in the video, I believe the bias column vector should be dimension k by 1 instead of n by 1 as you express in the video. After multiplying the weight matrix (k by n) by the activation matrix (n by 1) the resulting matrix dimension should be k by 1.

Hope you continue to output fantastic content 🙂

Your channel name and symbol reminds me of the Stargate SG-1 episode with the Tobin Mine combination lol

This is the best 101 video about ML and NN!

Thank you!

i am confusion

Great video, brings a lot of light into the topic in an easy way to understand. Never seen MNIST so great explained! Well done!

Haven't watched yet, but I'm super skeptical we have any idea where the ground actually is, or a million things in between.

Now we got Deep Fakes thanks to the Artificial Neural Network technology! Get ready for mass confusion and possibly World War 3. THIS IS ANOTHER CHINESE REVOLUTION!!! Now you don't need to work so hard to pay the high fees of the Screen Actor's Guild and go to film or acting school and try diligently forever to be a productive actor! This is the easy way to become an instant celebrity and acquire fame without ever being associated with a film studio!

I am studying Computer Science and this video has really improved my understanding of how Neural Networks actually work.

Thank you 🙂

this is V E R Y good !!

Mother nature outdone herself when she designed the human brain… its so complicated that it doesnt even understand how it works LOL

thank you! another great video!

Awesome video, really fascinating!

number of spots in the hidden layer shouldn't be more ??

The son of Lisha li and sander would've IQ of 300.

You're a god, Grant.

bacd Answer

That's certainly not how the brain and its neurons work but human is creating a way to convert things into numbers and numbers into another meaning number. That's good for machine to process data but I'm not sure if it can become a new intelligence or not. Let' s see.

Hey, werent the beginning test sample numbers used to train an Neural network made of a sheet of glass ?

Will you please suggest me a book to learn machine learning, please?

Il campo elettromagnetico umano e' come quello del pianeta il cervello come universo

Amazing

i understood everything

but i am having feeling that i just don't remember anything 😂

is it normal?

this is my first time watching a video from 3blue1brown.

and i just become a fan. thanx! 😊

Very nicely explained

How could anyone downvote this? Bar none, the best neural net intro vid series ever.

🗽

It is an awesome explanation. Thanks so much! One thing to correct, i believe the bias vector is till Bk instead of Bn.

… wenn jeder mit jedem vernetzt ist – und so in kürzester Zeit untereinander Infos ausgetauscht werden können.