1
00:00:00,330 --> 00:00:05,910
Hi and welcome to this part of the course where we actually get our feet wet and start using some code

2
00:00:05,910 --> 00:00:10,370
and building our first convolutional neural network using Python.

3
00:00:11,280 --> 00:00:16,230
So now let's dive into the code into Google Cloud and get started with this lesson.

4
00:00:17,400 --> 00:00:24,990
OK, so you're here on Google Cloud and I assume you've unzipped all of the course coded into your Google

5
00:00:24,990 --> 00:00:32,640
Drive, and you can place the code at the course code called Modern Computer Vision to Folder and you'll

6
00:00:32,640 --> 00:00:34,070
call up in the books directory.

7
00:00:34,110 --> 00:00:36,940
It's fine if you leave it outside, you can put it any way you want.

8
00:00:36,960 --> 00:00:42,870
I just have it here because it's good to keep the stuff organized, so we have folders here.

9
00:00:43,380 --> 00:00:46,830
If you've done the open to be part of the course, you would have seen all of the course.

10
00:00:46,830 --> 00:00:50,910
Could a full open CV right here, the all the fortysomething notebooks.

11
00:00:51,540 --> 00:00:55,080
Now we're going to start the deep learning part of the course.

12
00:00:55,590 --> 00:01:01,530
So let's dive into the deep learning part of the diplomatic folder and you'll see all of the course.

13
00:01:01,530 --> 00:01:02,000
Good here.

14
00:01:02,010 --> 00:01:07,950
There's a lot of notebooks here, a lot of projects, a lot of invaluable lessons because I'm a computer

15
00:01:07,950 --> 00:01:14,310
vision engineer practitioner and researcher, and I routinely routinely look up my own notebooks because

16
00:01:14,310 --> 00:01:16,620
there's just so much knowledge and you tend to forget things.

17
00:01:17,070 --> 00:01:20,640
So it's a very good resource for just having all of these notebooks here.

18
00:01:21,300 --> 00:01:27,090
So the first one we're going to do is to pay to watch CNN tutorial using the amnesty dataset.

19
00:01:27,540 --> 00:01:33,360
Now the amnesty, the said, is a set of a very famous computer vision data set of handwritten digits

20
00:01:33,780 --> 00:01:35,760
that was compiled by USPS.

21
00:01:36,300 --> 00:01:37,590
Maybe in the 90s, I believe.

22
00:01:38,040 --> 00:01:43,800
And it's been the benchmark for early computer vision algorithms and then deleted scenes and deep of

23
00:01:43,800 --> 00:01:45,840
the deep different stuff over the years.

24
00:01:46,140 --> 00:01:50,070
So it's a really good baseline dataset to use to experiment on.

25
00:01:50,790 --> 00:01:52,540
So let's open this notebook out.

26
00:01:52,560 --> 00:01:55,410
I already have it up in here because I was just reading some stuff before.

27
00:01:56,190 --> 00:02:02,660
So let's take a tour of the notebook this you can see we have the definition of what we're doing here,

28
00:02:02,680 --> 00:02:09,780
creating a simple CNN amnesty to set, which is handwritten digits and a list of 10 different things

29
00:02:09,780 --> 00:02:13,080
here that we're going to do going to be doing in this notebook.

30
00:02:13,680 --> 00:02:20,670
So a lot of my notebooks in this section in this part of Texas have numbers one, two three, whatever,

31
00:02:21,510 --> 00:02:22,620
and that's how we teach.

32
00:02:23,190 --> 00:02:29,040
I teach in blocks and each block is meant to be pretty, pretty simple, small lesson.

33
00:02:29,520 --> 00:02:33,540
And it's I think it's a good way to split up the lessons here.

34
00:02:33,990 --> 00:02:35,430
So let's get started.

35
00:02:35,520 --> 00:02:39,660
So firstly, we want to build a CNN using by touch.

36
00:02:39,810 --> 00:02:40,740
What do we need to do?

37
00:02:41,130 --> 00:02:43,560
Well, we need to import these libraries.

38
00:02:44,190 --> 00:02:48,600
So the first library you're going to import is PyTorch and to import PyTorch.

39
00:02:48,930 --> 00:02:54,210
It's actually just a short torch when we when Facebook made this thing, called the torch.

40
00:02:54,720 --> 00:02:56,700
So we just import torch.

41
00:02:56,760 --> 00:02:58,830
We don't actually have to put the word play torch.

42
00:02:59,190 --> 00:03:03,210
It's a bit confusing sometimes, because that's a foolish offensive to carry out such a scare us.

43
00:03:03,750 --> 00:03:09,480
But a lot of libraries do have different names, depending on why maybe there was existing play torch

44
00:03:09,480 --> 00:03:09,930
for those.

45
00:03:10,470 --> 00:03:12,360
But we have a torch here.

46
00:03:13,260 --> 00:03:20,250
Next, we import something called torch vision, and torch vision is a set of accompanying libraries

47
00:03:20,250 --> 00:03:23,580
that go together with the Torch Library or the Torch Library.

48
00:03:23,940 --> 00:03:29,280
I'm going to use PI torch and torch interchangeably and most likely will simply torch because it's just

49
00:03:29,940 --> 00:03:31,080
easier to say, to be fair.

50
00:03:31,590 --> 00:03:34,830
So let's take a look at this here.

51
00:03:35,340 --> 00:03:36,420
So what?

52
00:03:36,480 --> 00:03:37,860
Why do we need torch vision?

53
00:03:38,370 --> 00:03:45,630
Well, Torch Mission has a lot of data sets and other useful utility functions that we use with the

54
00:03:45,630 --> 00:03:48,800
Torch Library to make things much easier.

55
00:03:48,810 --> 00:03:49,860
So you'll get started.

56
00:03:49,860 --> 00:03:50,840
Don't worry about this yet.

57
00:03:50,850 --> 00:03:53,790
You'll get started and you'll see what all these libraries do.

58
00:03:54,120 --> 00:03:57,090
So don't don't get consumed too much yet.

59
00:03:57,690 --> 00:03:59,730
It's all going to make sense shortly.

60
00:04:00,480 --> 00:04:05,680
So you see, we import two things we import what vision and then we import the specific function here

61
00:04:05,700 --> 00:04:06,530
transforms.

62
00:04:07,350 --> 00:04:10,950
And we want to be important to watch vision that transforms and we call it transforms.

63
00:04:10,950 --> 00:04:14,130
And it could transform the very useful functions.

64
00:04:14,130 --> 00:04:17,250
And I'll demonstrate why later on.

65
00:04:18,030 --> 00:04:22,410
Next, we import some torch libraries here that we are going to use to build CNN.

66
00:04:22,890 --> 00:04:27,370
So we import torchlight optim as optim as well as entertaining.

67
00:04:27,630 --> 00:04:33,480
And what we used as command in Python is just so that we don't have to write this continuously.

68
00:04:33,480 --> 00:04:33,900
No code.

69
00:04:34,380 --> 00:04:35,750
Makes it easier to read.

70
00:04:36,000 --> 00:04:41,280
So it's a good thing to import a function like this towards the OPTIM as often.

71
00:04:42,060 --> 00:04:46,770
But this is really that object technically right up here importing not the function.

72
00:04:47,520 --> 00:04:52,050
And then lastly, is an important line that you constantly see in all the Python Watch lessons.

73
00:04:52,620 --> 00:04:53,640
I'll be using CUDA.

74
00:04:53,790 --> 00:04:54,800
So what is CUDA?

75
00:04:55,110 --> 00:04:59,730
Well, I'll probably put up a lesson about CUDA afterward, but.

76
00:05:00,250 --> 00:05:08,050
Is the video deep learning both Nvidia duping you accelerating library, that deep learning libraries

77
00:05:08,050 --> 00:05:11,740
used to do the calculations in the back end speed of these things on GPUs?

78
00:05:12,340 --> 00:05:19,960
So if CUDA is available, PyTorch will use CUDA and it'll become vastly faster and more efficient.

79
00:05:20,380 --> 00:05:26,020
However, if CUDA is unavailable, then you're going to be using the CPU instead, which is a lot slower.

80
00:05:26,230 --> 00:05:27,590
However, it still does work.

81
00:05:27,640 --> 00:05:34,510
So to get the GPU on CoLab, this notebook should open automatically with the GPU.

82
00:05:34,990 --> 00:05:40,960
However, if you go to edit notebook settings, you can see you can get the GPU, CPU and none.

83
00:05:41,380 --> 00:05:45,440
That means you're using strictly the CPU can even increase your RAM.

84
00:05:45,460 --> 00:05:50,230
Most of our listeners don't need to increase to higher, so that's fine.

85
00:05:50,230 --> 00:05:56,410
You can leave it as is, but if you're if your notebook is sitting on none, change it to GPU and then

86
00:05:57,040 --> 00:05:58,140
won't change the GPU.

87
00:05:58,240 --> 00:06:01,990
The notebook will restart so we can lose everything for that point.

88
00:06:02,290 --> 00:06:09,970
As in all the things, he said, the notebook will still be there and for no change in the GPU and run

89
00:06:09,970 --> 00:06:13,000
this block of code, which I've already run, says GPU available.

90
00:06:13,720 --> 00:06:18,130
And it takes about five or six seconds to import these packages, and you only need to do this once

91
00:06:18,310 --> 00:06:19,030
in your notebook.

92
00:06:19,450 --> 00:06:20,620
You don't need to do this again.

93
00:06:21,040 --> 00:06:29,440
So the torch that CUDA is available is a function that tells us a Boolean Boolean function sends a bullet

94
00:06:29,440 --> 00:06:34,060
argument that tells us what the CUDA is available and what that means.

95
00:06:34,060 --> 00:06:37,240
You going to be using the GPU if it is or CPU, if it's not.

96
00:06:37,780 --> 00:06:43,280
And we have this device variable we use to call it, but occasionally went by to its functions that

97
00:06:43,280 --> 00:06:45,730
would be need to send things to the CPU or CPU.

98
00:06:46,360 --> 00:06:47,960
So don't worry too much about this yet.

99
00:06:47,980 --> 00:06:52,150
This is just setting sphere to what we're using, so we want to be using the GPU.

100
00:06:52,540 --> 00:06:59,450
So if cooler is available, it will automatically set device equal to CUDA and any any function we use

101
00:06:59,450 --> 00:07:02,650
and pay too much to has the device as an input parameter.

102
00:07:02,660 --> 00:07:04,090
It'll know what it wants to.

103
00:07:04,220 --> 00:07:12,130
We want to use GPU, so let's stop there for now and we'll move on to the transformer lesson.

104
00:07:12,430 --> 00:07:13,900
So I'll see you in the next section.
