1
00:00:00,000 --> 00:00:03,195
Here's the transfer learning
workbook from this lesson.

2
00:00:03,195 --> 00:00:04,340
Let's step through it,

3
00:00:04,340 --> 00:00:06,520
and when we're done, you
can try it for yourself.

4
00:00:06,520 --> 00:00:08,850
The first cell downloads
the weights for

5
00:00:08,850 --> 00:00:10,830
a pre-trained inception network,

6
00:00:10,830 --> 00:00:12,810
and then instantiates
a new instance

7
00:00:12,810 --> 00:00:14,520
of it using those weights.

8
00:00:14,520 --> 00:00:17,160
We will pull one of
the convolutional layers

9
00:00:17,160 --> 00:00:18,420
as our input layer,

10
00:00:18,420 --> 00:00:19,770
and then take its output.

11
00:00:19,770 --> 00:00:21,720
We call this last output.

12
00:00:21,720 --> 00:00:23,940
Now, we'll set up
our model taking

13
00:00:23,940 --> 00:00:26,160
the last output as
the input to it.

14
00:00:26,160 --> 00:00:29,145
That'll be flattened, and then
there'll be a dense layer,

15
00:00:29,145 --> 00:00:31,560
a dropout, and an output layer.

16
00:00:31,560 --> 00:00:33,440
The next cell will download

17
00:00:33,440 --> 00:00:36,320
the abbreviated version
of cats versus dogs,

18
00:00:36,320 --> 00:00:39,230
unzip it into training and
validation directories,

19
00:00:39,230 --> 00:00:41,330
and then set up
the image generators.

20
00:00:41,330 --> 00:00:42,710
The training one will use

21
00:00:42,710 --> 00:00:45,305
augmentation as we've
explored before.

22
00:00:45,305 --> 00:00:47,750
We can then see that
the images are being

23
00:00:47,750 --> 00:00:50,240
loaded and segregated
into classes correctly,

24
00:00:50,240 --> 00:00:53,360
2,000 for training,
1,000 for validation.

25
00:00:53,360 --> 00:00:55,105
We'll now start the training.

26
00:00:55,105 --> 00:00:56,760
I'm only going to do 20 epochs.

27
00:00:56,760 --> 00:00:58,384
Keep an eye on the accuracy

28
00:00:58,384 --> 00:01:00,740
and validation accuracy metrics.

29
00:01:00,740 --> 00:01:03,455
I'm speeding up the video
to save a little time.

30
00:01:03,455 --> 00:01:05,570
But as you can see,
the training accuracy

31
00:01:05,570 --> 00:01:07,435
is steadily increasing,

32
00:01:07,435 --> 00:01:09,320
and the validation accuracy is

33
00:01:09,320 --> 00:01:11,510
settling in about the mid 90's.

34
00:01:11,510 --> 00:01:13,790
By the time we're done,
the training accuracy

35
00:01:13,790 --> 00:01:15,290
is around 90 percent,

36
00:01:15,290 --> 00:01:18,230
and the validation is
close to 97 percent.

37
00:01:18,230 --> 00:01:19,865
That's in pretty good shape.

38
00:01:19,865 --> 00:01:22,100
So let's plot the 20 epochs and

39
00:01:22,100 --> 00:01:24,185
we can see that
the curves are in sync.

40
00:01:24,185 --> 00:01:27,620
This is a good sign that
we're avoiding overfitting.

41
00:01:27,620 --> 00:01:29,950
So that's it for this lesson.

42
00:01:29,950 --> 00:01:32,090
In this and in
the last few lessons,

43
00:01:32,090 --> 00:01:33,620
we spent a lot of time looking at

44
00:01:33,620 --> 00:01:35,375
convolutional neural networks

45
00:01:35,375 --> 00:01:37,775
for classifying binary values.

46
00:01:37,775 --> 00:01:40,160
Of course another scenario
happens when you

47
00:01:40,160 --> 00:01:42,500
have to classify
multiple objects.

48
00:01:42,500 --> 00:01:43,940
So in the next lesson,

49
00:01:43,940 --> 00:01:46,740
we'll look at what you have
to do to achieve that.