Hi and welcome to this part of the course where we actually get our feet wet and start using some code
and building our first convolutional neural network using Python.
So now let's dive into the code into Google Cloud and get started with this lesson.
OK, so you're here on Google Cloud and I assume you've unzipped all of the course coded into your Google
Drive, and you can place the code at the course code called Modern Computer Vision to Folder and you'll
call up in the books directory.
It's fine if you leave it outside, you can put it any way you want.
I just have it here because it's good to keep the stuff organized, so we have folders here.
If you've done the open to be part of the course, you would have seen all of the course.
Could a full open CV right here, the all the fortysomething notebooks.
Now we're going to start the deep learning part of the course.
So let's dive into the deep learning part of the diplomatic folder and you'll see all of the course.
Good here.
There's a lot of notebooks here, a lot of projects, a lot of invaluable lessons because I'm a computer
vision engineer practitioner and researcher, and I routinely routinely look up my own notebooks because
there's just so much knowledge and you tend to forget things.
So it's a very good resource for just having all of these notebooks here.
So the first one we're going to do is to pay to watch CNN tutorial using the amnesty dataset.
Now the amnesty, the said, is a set of a very famous computer vision data set of handwritten digits
that was compiled by USPS.
Maybe in the 90s, I believe.
And it's been the benchmark for early computer vision algorithms and then deleted scenes and deep of
the deep different stuff over the years.
So it's a really good baseline dataset to use to experiment on.
So let's open this notebook out.
I already have it up in here because I was just reading some stuff before.
So let's take a tour of the notebook this you can see we have the definition of what we're doing here,
creating a simple CNN amnesty to set, which is handwritten digits and a list of 10 different things
here that we're going to do going to be doing in this notebook.
So a lot of my notebooks in this section in this part of Texas have numbers one, two three, whatever,
and that's how we teach.
I teach in blocks and each block is meant to be pretty, pretty simple, small lesson.
And it's I think it's a good way to split up the lessons here.
So let's get started.
So firstly, we want to build a CNN using by touch.
What do we need to do?
Well, we need to import these libraries.
So the first library you're going to import is PyTorch and to import PyTorch.
It's actually just a short torch when we when Facebook made this thing, called the torch.
So we just import torch.
We don't actually have to put the word play torch.
It's a bit confusing sometimes, because that's a foolish offensive to carry out such a scare us.
But a lot of libraries do have different names, depending on why maybe there was existing play torch
for those.
But we have a torch here.
Next, we import something called torch vision, and torch vision is a set of accompanying libraries
that go together with the Torch Library or the Torch Library.
I'm going to use PI torch and torch interchangeably and most likely will simply torch because it's just
easier to say, to be fair.
So let's take a look at this here.
So what?
Why do we need torch vision?
Well, Torch Mission has a lot of data sets and other useful utility functions that we use with the
Torch Library to make things much easier.
So you'll get started.
Don't worry about this yet.
You'll get started and you'll see what all these libraries do.
So don't don't get consumed too much yet.
It's all going to make sense shortly.
So you see, we import two things we import what vision and then we import the specific function here
transforms.
And we want to be important to watch vision that transforms and we call it transforms.
And it could transform the very useful functions.
And I'll demonstrate why later on.
Next, we import some torch libraries here that we are going to use to build CNN.
So we import torchlight optim as optim as well as entertaining.
And what we used as command in Python is just so that we don't have to write this continuously.
No code.
Makes it easier to read.
So it's a good thing to import a function like this towards the OPTIM as often.
But this is really that object technically right up here importing not the function.
And then lastly, is an important line that you constantly see in all the Python Watch lessons.
I'll be using CUDA.
So what is CUDA?
Well, I'll probably put up a lesson about CUDA afterward, but.
Is the video deep learning both Nvidia duping you accelerating library, that deep learning libraries
used to do the calculations in the back end speed of these things on GPUs?
So if CUDA is available, PyTorch will use CUDA and it'll become vastly faster and more efficient.
However, if CUDA is unavailable, then you're going to be using the CPU instead, which is a lot slower.
However, it still does work.
So to get the GPU on CoLab, this notebook should open automatically with the GPU.
However, if you go to edit notebook settings, you can see you can get the GPU, CPU and none.
That means you're using strictly the CPU can even increase your RAM.
Most of our listeners don't need to increase to higher, so that's fine.
You can leave it as is, but if you're if your notebook is sitting on none, change it to GPU and then
won't change the GPU.
The notebook will restart so we can lose everything for that point.
As in all the things, he said, the notebook will still be there and for no change in the GPU and run
this block of code, which I've already run, says GPU available.
And it takes about five or six seconds to import these packages, and you only need to do this once
in your notebook.
You don't need to do this again.
So the torch that CUDA is available is a function that tells us a Boolean Boolean function sends a bullet
argument that tells us what the CUDA is available and what that means.
You going to be using the GPU if it is or CPU, if it's not.
And we have this device variable we use to call it, but occasionally went by to its functions that
would be need to send things to the CPU or CPU.
So don't worry too much about this yet.
This is just setting sphere to what we're using, so we want to be using the GPU.
So if cooler is available, it will automatically set device equal to CUDA and any any function we use
and pay too much to has the device as an input parameter.
It'll know what it wants to.
We want to use GPU, so let's stop there for now and we'll move on to the transformer lesson.
So I'll see you in the next section.