1
00:00:00,910 --> 00:00:02,530
All of the layers have names, so

2
00:00:02,530 --> 00:00:06,460
you can look up the name of the last
layer that you want to use.

3
00:00:06,460 --> 00:00:08,020
If you inspect the summary,

4
00:00:08,020 --> 00:00:11,650
you'll see that the bottom
layers have convolved to 3 by 3.

5
00:00:11,650 --> 00:00:14,780
But I want to use something
with a little more information.

6
00:00:14,780 --> 00:00:17,450
So I moved up the model
description to find mixed7,

7
00:00:18,640 --> 00:00:21,700
which is the output of a lot of
convolution that are 7 by 7.

8
00:00:21,700 --> 00:00:25,980
You don't have to use this layer and
is fun to experiment with others.

9
00:00:25,980 --> 00:00:28,880
But with this code, I'm going to
grab that layer from inception and

10
00:00:28,880 --> 00:00:29,690
take it to output.

11
00:00:31,070 --> 00:00:35,295
So now we'll define our new model, taking
the output from the inception model's

12
00:00:35,295 --> 00:00:39,290
mixed7 layer,
which we had called last_ouput.

13
00:00:39,290 --> 00:00:43,090
This should look exactly like the dense
models that you created way back at

14
00:00:43,090 --> 00:00:44,300
the start of this course.

15
00:00:44,300 --> 00:00:46,240
The code is a little different, but

16
00:00:46,240 --> 00:00:48,380
this is just a different way
of using the layers API.

17
00:00:48,380 --> 00:00:52,380
You start by flattening the input,

18
00:00:52,380 --> 00:00:55,500
which just happens to be
the output from inception.

19
00:00:55,500 --> 00:00:57,790
And then add a Dense hidden layer.

20
00:00:57,790 --> 00:01:00,920
And then your output layer
which has just one neuron

21
00:01:00,920 --> 00:01:04,960
activated by a sigmoid to
classify between two items.

22
00:01:04,960 --> 00:01:09,040
You can then create a model
using the Model abstract class.

23
00:01:09,040 --> 00:01:12,570
And passing at the input and the layers
definition that you've just created.

24
00:01:13,770 --> 00:01:17,430
And then you compile it as before with
an optimizer and a loss function and

25
00:01:17,430 --> 00:01:19,350
the metrics that you want to collect.

26
00:01:20,370 --> 00:01:23,240
I won't go into all the codes to
download cats versus dogs again,

27
00:01:23,240 --> 00:01:25,490
it's in the workbook
if you want to use it.

28
00:01:25,490 --> 00:01:29,610
But as before you're going to augment
the images with the image generator.

29
00:01:29,610 --> 00:01:33,970
Then, as before, we can get our
training data from the generator

30
00:01:33,970 --> 00:01:39,000
by flowing from the specified directory
and going through all the augmentations.

31
00:01:39,000 --> 00:01:42,890
And now we can train as before
with model.fit_generator.

32
00:01:42,890 --> 00:01:44,569
I'm going to run it for 100 epochs.

33
00:01:45,640 --> 00:01:49,260
What's interesting if you do this,
is that you end up with another but

34
00:01:49,260 --> 00:01:51,910
a different overfitting situation.

35
00:01:51,910 --> 00:01:55,770
Here is the graph of the accuracy
of training versus validation.

36
00:01:55,770 --> 00:01:57,860
As you can see, while it started out well,

37
00:01:57,860 --> 00:02:02,570
the validation is diverging away from
the training in a really bad way.

38
00:02:02,570 --> 00:02:04,040
So, how do we fix this?

39
00:02:04,040 --> 00:02:05,500
We'll take a look at
that in the next lesson.