1
00:00:00,390 --> 00:00:03,580
Okay, in the previous video
you took a look at a notebook

2
00:00:03,580 --> 00:00:08,130
that trained a convolutional neural
network that classified cats versus dogs.

3
00:00:08,130 --> 00:00:09,660
Now let's take a look at how that worked.

4
00:00:10,730 --> 00:00:13,740
Let's return to the notebook and
take a look at the code that

5
00:00:13,740 --> 00:00:17,960
plots the outputs of the convolutions
in max pooling layers.

6
00:00:17,960 --> 00:00:21,600
The key to this is understanding
the model.layers API,

7
00:00:21,600 --> 00:00:23,650
which allows you to find the outputs and

8
00:00:23,650 --> 00:00:26,900
iterate through them, creating
a visualization model for each one.

9
00:00:28,140 --> 00:00:31,060
We can then load a random
image into an array and

10
00:00:31,060 --> 00:00:33,950
pass it to the predict method
of the visualization model.

11
00:00:35,050 --> 00:00:39,750
The variable to keep an eye on is
display_grid which can be constructed from

12
00:00:39,750 --> 00:00:43,000
x which is read as a feature map and
processed a little for

13
00:00:43,000 --> 00:00:44,530
visibility in the central loop.

14
00:00:45,790 --> 00:00:48,450
We'll then render each of
the convolutions of the image,

15
00:00:48,450 --> 00:00:51,190
plus their pooling,
then another convolution, etc.

16
00:00:52,260 --> 00:00:56,814
You can see images such as the dog's nose
being highlighted in many of the images on

17
00:00:56,814 --> 00:00:57,413
the left.

18
00:00:59,200 --> 00:01:03,040
We can then run it again to
get another random image.

19
00:01:03,040 --> 00:01:06,790
And while at first glance this appears
to be a frog, if you look closely it's

20
00:01:06,790 --> 00:01:12,220
a Siamese cat with a dark head and
dark paws towards the right of the frame.

21
00:01:12,220 --> 00:01:16,110
It's hard to see if any of
the convolutions lock down on a feature.

22
00:01:16,110 --> 00:01:19,680
Except maybe the synonymous
upright tail of the cat,

23
00:01:19,680 --> 00:01:23,020
we can see that vertical dark line
in a number of the convolutions.

24
00:01:25,030 --> 00:01:26,470
And let's give it one more try.

25
00:01:26,470 --> 00:01:28,230
We can see what's clearly a dog, and

26
00:01:28,230 --> 00:01:32,040
how the ears of the dog
are represented very strongly.

27
00:01:32,040 --> 00:01:36,590
Features like this moving through the
convolutions and being labeled as doglike

28
00:01:36,590 --> 00:01:38,940
could end up being called something
like a floppy ear detector.