So let's now take a look at the definition of
the neural network that we'll use to
classify horses versus humans.
It's very similar to what you
just used for the fashion items,
but there are a few minor differences based on this data,
and the fact that we're using generators.
So here's the code.
As you can see, it's the sequential as before with
convolutions and pooling before
we get to the dense layers at the bottom.
But let's highlight some of the differences.
First of all, you'll notice that there are
three sets of convolution pooling layers at the top.
This reflects the higher complexity
and size of the images.
Remember our earlier our 28 by
28.5 to 13 and then five before flattening,
well, now we have 300 by 300.
So we start at 298 by 298 and then have that etc., etc.
until by the end, we're at a 35 by 35 image.
We can even add another couple of layers to this if
we wanted to get to the same ballpark size as previously,
but we'll keep it at three for now.
Another thing to pay attention to is the input shape.
We resize their images to be
300 by 300 as they were loaded,
but they're also color images.
So there are three bytes per pixel.
One byte for the red, one for green,
and one for the blue channel, and that's
a common 24-bit color pattern.
If you're paying really close attention,
you can see that the output layer has also changed.
Remember before when you created the output layer,
you had one neuron per class,
but now there's only one neuron for two classes.
That's because we're using
a different activation function where
sigmoid is great for binary classification,
where one class will tend towards
zero and the other class tending towards one.
You could use two neurons here if you want,
and the same softmax function as before,
but for binary this is a bit more efficient.
If you want you can experiment with
the workbook and give it a try yourself.
Now, if we take a look at our model summary,
we can see the journey of
the image data through the convolutions
The 300 by 300 becomes 298 by
298 after the three by three filter,
it gets pulled to 149 by
149 which in turn gets reduced to
73 by 73 after
the filter that then gets pulled to 35 by 35,
this will then get flattened,
so 64 convolutions that are 35
squared and shape will get fed into the DNN.
If you multiply 35 by 35 by 64,
you get 78,400, and that's
the shape of the data once
it comes out of the convolutions.
If we had just fed raw
300 by 300 images without the convolutions,
that would be over 90,000 values.
So we've already reduced it quite a bit.