1
00:00:00,000 --> 00:00:02,310
Okay. So now we will look at

2
00:00:02,310 --> 00:00:04,860
the code for the neural
network definition.

3
00:00:04,860 --> 00:00:06,360
Remember last time we had a

4
00:00:06,360 --> 00:00:08,390
sequential with
just one layer in it.

5
00:00:08,390 --> 00:00:10,575
Now we have three layers.

6
00:00:10,575 --> 00:00:12,750
The important things
to look at are

7
00:00:12,750 --> 00:00:14,775
the first and the last layers.

8
00:00:14,775 --> 00:00:17,355
The last layer has
10 neurons in it

9
00:00:17,355 --> 00:00:20,580
because we have ten classes
of clothing in the dataset.

10
00:00:20,580 --> 00:00:22,245
They should always match.

11
00:00:22,245 --> 00:00:24,930
The first layer is
a flatten layer

12
00:00:24,930 --> 00:00:27,465
with the input shaping 28 by 28.

13
00:00:27,465 --> 00:00:30,855
Now, if you remember
our images are 28 by 28,

14
00:00:30,855 --> 00:00:33,290
so we're specifying that this is

15
00:00:33,290 --> 00:00:36,110
the shape that we should
expect the data to be in.

16
00:00:36,110 --> 00:00:38,390
Flatten takes this 28 by 28

17
00:00:38,390 --> 00:00:41,585
square and turns it into
a simple linear array.

18
00:00:41,585 --> 00:00:44,390
The interesting stuff
happens in the middle layer,

19
00:00:44,390 --> 00:00:46,445
sometimes also called
a hidden layer.

20
00:00:46,445 --> 00:00:48,750
This is a 128 neurons in it,

21
00:00:48,750 --> 00:00:50,480
and I'd like you to think about

22
00:00:50,480 --> 00:00:52,475
these as variables in a function.

23
00:00:52,475 --> 00:00:55,735
Maybe call them x1, x2 x3, etc.

24
00:00:55,735 --> 00:00:58,010
Now, there exists a rule that

25
00:00:58,010 --> 00:01:00,170
incorporates all of these that

26
00:01:00,170 --> 00:01:02,240
turns the 784 values of

27
00:01:02,240 --> 00:01:05,060
an ankle boot into
the value nine,

28
00:01:05,060 --> 00:01:07,875
and similar for all
of the other 70,000.

29
00:01:07,875 --> 00:01:10,100
It's too complex
a function for you to

30
00:01:10,100 --> 00:01:12,379
see by mapping
the images yourself,

31
00:01:12,379 --> 00:01:14,425
but that's what
a neural net does.

32
00:01:14,425 --> 00:01:17,030
So, for example, if you
then say the function

33
00:01:17,030 --> 00:01:20,000
was y equals w1 times x1,

34
00:01:20,000 --> 00:01:21,710
plus w2 times x2,

35
00:01:21,710 --> 00:01:23,465
plus w3 times x3,

36
00:01:23,465 --> 00:01:27,095
all the way up to
a w128 times x128.

37
00:01:27,095 --> 00:01:29,555
By figuring out the values of w,

38
00:01:29,555 --> 00:01:30,785
then y will be nine,

39
00:01:30,785 --> 00:01:32,725
when you have the input
value of the shoe.

40
00:01:32,725 --> 00:01:34,910
You'll see that it's
doing something very,

41
00:01:34,910 --> 00:01:37,010
very similar to
what we did earlier

42
00:01:37,010 --> 00:01:39,560
when we figured out y
equals 2x minus one.

43
00:01:39,560 --> 00:01:41,255
In that case the two,

44
00:01:41,255 --> 00:01:42,605
was the weight of x.

45
00:01:42,605 --> 00:01:46,150
So, I'm saying y equals
w1 times x1, etc.

46
00:01:46,150 --> 00:01:49,370
Now, don't worry if this
isn't very clear right now.

47
00:01:49,370 --> 00:01:51,320
Over time, you will
get the hang of it,

48
00:01:51,320 --> 00:01:52,745
seeing that it works,

49
00:01:52,745 --> 00:01:54,710
and there's also some tools
that will allow you

50
00:01:54,710 --> 00:01:57,025
to peek inside to
see what's going on.

51
00:01:57,025 --> 00:01:59,810
The important thing for now
is to get the code working,

52
00:01:59,810 --> 00:02:02,765
so you can see a classification
scenario for yourself.

53
00:02:02,765 --> 00:02:05,480
You can also tune
the neural network by adding,

54
00:02:05,480 --> 00:02:08,405
removing and changing
layer size to see the impact.

55
00:02:08,405 --> 00:02:10,705
You'll do that in
the next exercise.

56
00:02:10,705 --> 00:02:13,300
Also, if you want to go further,

57
00:02:13,300 --> 00:02:16,115
checkout this tutorial
from Andrew on YouTube,

58
00:02:16,115 --> 00:02:19,235
which will clarify
how dense connected layer's work

59
00:02:19,235 --> 00:02:22,100
from the theoretical and
mathematical perspective.

60
00:02:22,100 --> 00:02:25,350
But for now, let's
get back to the code.