Okay, in the previous video you took a look at a notebook
that trained a convolutional neural network that classified cats versus dogs.
Now let's take a look at how that worked.
Let's return to the notebook and take a look at the code that
plots the outputs of the convolutions in max pooling layers.
The key to this is understanding the model.layers API,
which allows you to find the outputs and
iterate through them, creating a visualization model for each one.
We can then load a random image into an array and
pass it to the predict method of the visualization model.
The variable to keep an eye on is display_grid which can be constructed from
x which is read as a feature map and processed a little for
visibility in the central loop.
We'll then render each of the convolutions of the image,
plus their pooling, then another convolution, etc.
You can see images such as the dog's nose being highlighted in many of the images on
the left.
We can then run it again to get another random image.
And while at first glance this appears to be a frog, if you look closely it's
a Siamese cat with a dark head and dark paws towards the right of the frame.
It's hard to see if any of the convolutions lock down on a feature.
Except maybe the synonymous upright tail of the cat,
we can see that vertical dark line in a number of the convolutions.
And let's give it one more try.
We can see what's clearly a dog, and
how the ears of the dog are represented very strongly.
Features like this moving through the convolutions and being labeled as doglike
could end up being called something like a floppy ear detector.