Okay. So now we will look at
the code for the neural network definition.
Remember last time we had a
sequential with just one layer in it.
Now we have three layers.
The important things to look at are
the first and the last layers.
The last layer has 10 neurons in it
because we have ten classes of clothing in the dataset.
They should always match.
The first layer is a flatten layer
with the input shaping 28 by 28.
Now, if you remember our images are 28 by 28,
so we're specifying that this is
the shape that we should expect the data to be in.
Flatten takes this 28 by 28
square and turns it into a simple linear array.
The interesting stuff happens in the middle layer,
sometimes also called a hidden layer.
This is a 128 neurons in it,
and I'd like you to think about
these as variables in a function.
Maybe call them x1, x2 x3, etc.
Now, there exists a rule that
incorporates all of these that
turns the 784 values of
an ankle boot into the value nine,
and similar for all of the other 70,000.
It's too complex a function for you to
see by mapping the images yourself,
but that's what a neural net does.
So, for example, if you then say the function
was y equals w1 times x1,
plus w2 times x2,
plus w3 times x3,
all the way up to a w128 times x128.
By figuring out the values of w,
then y will be nine,
when you have the input value of the shoe.
You'll see that it's doing something very,
very similar to what we did earlier
when we figured out y equals 2x minus one.
In that case the two,
was the weight of x.
So, I'm saying y equals w1 times x1, etc.
Now, don't worry if this isn't very clear right now.
Over time, you will get the hang of it,
seeing that it works,
and there's also some tools that will allow you
to peek inside to see what's going on.
The important thing for now is to get the code working,
so you can see a classification scenario for yourself.
You can also tune the neural network by adding,
removing and changing layer size to see the impact.
You'll do that in the next exercise.
Also, if you want to go further,
checkout this tutorial from Andrew on YouTube,
which will clarify how dense connected layer's work
from the theoretical and mathematical perspective.
But for now, let's get back to the code.