1
00:00:00,000 --> 00:00:01,980
So let's take a look at how we

2
00:00:01,980 --> 00:00:03,885
would achieve this in code.

3
00:00:03,885 --> 00:00:06,020
We'll start with the inputs.

4
00:00:06,020 --> 00:00:09,295
In particular, we'll be
using the keras layers API,

5
00:00:09,295 --> 00:00:10,775
to pick at the layers,

6
00:00:10,775 --> 00:00:13,320
and to understand
which ones we want to use,

7
00:00:13,320 --> 00:00:15,060
and which ones we
want to retrain.

8
00:00:15,060 --> 00:00:17,460
A copy of the
pretrained weights for

9
00:00:17,460 --> 00:00:20,880
the inception neural network
is saved at this URL.

10
00:00:20,880 --> 00:00:22,980
Think of this as a snapshot of

11
00:00:22,980 --> 00:00:24,990
the model after being trained.

12
00:00:24,990 --> 00:00:26,970
It's the parameters
that can then get

13
00:00:26,970 --> 00:00:29,070
loaded into the skeleton
of the model,

14
00:00:29,070 --> 00:00:31,185
to turn it back into
a trained model.

15
00:00:31,185 --> 00:00:33,675
So now if we want
to use inception,

16
00:00:33,675 --> 00:00:35,340
it's fortunate that keras has

17
00:00:35,340 --> 00:00:37,295
the model definition built in.

18
00:00:37,295 --> 00:00:39,110
So you instantiate that with

19
00:00:39,110 --> 00:00:41,630
the desired input shape
for your data,

20
00:00:41,630 --> 00:00:43,340
and specify that you don't want

21
00:00:43,340 --> 00:00:45,155
to use the built-in weights,

22
00:00:45,155 --> 00:00:47,905
but the snapshot that
you've just downloaded.

23
00:00:47,905 --> 00:00:51,965
The inception V3 has a
fully-connected layer at the top.

24
00:00:51,965 --> 00:00:54,800
So by setting
include_top to false,

25
00:00:54,800 --> 00:00:56,510
you're specifying that
you want to ignore

26
00:00:56,510 --> 00:00:59,045
this and get straight
to the convolutions.

27
00:00:59,045 --> 00:01:02,405
Now that I have my pretrained
model instantiated,

28
00:01:02,405 --> 00:01:05,060
I can iterate through
its layers and lock them,

29
00:01:05,060 --> 00:01:06,230
saying that they're not going to

30
00:01:06,230 --> 00:01:08,030
be trainable with this code.

31
00:01:08,030 --> 00:01:10,850
You can then print a summary
of your pretrained model

32
00:01:10,850 --> 00:01:14,300
with this code but be
prepared, it's huge.

33
00:01:14,300 --> 00:01:17,120
There's no way I can
fit it all in a slide,

34
00:01:17,120 --> 00:01:19,445
even if I use a two
point font like this.

35
00:01:19,445 --> 00:01:21,470
This is probably
less than 10 percent

36
00:01:21,470 --> 00:01:22,835
of the summary of the model.

37
00:01:22,835 --> 00:01:25,350
Try it in the notebook
for yourself.