-
INSTRUCTOR: Google
Colaboratory, or Colab for short
-
is the best way to get started
with artificial intelligence
-
and data science.
-
Everything you need all the
major libraries and tools
-
are already pre-installed for
you and pre-set up for you.
-
So by the time it
takes you to search
-
how to install
another software, you
-
can already be up and running
coding your data science
-
and artificial
intelligence code.
-
With Google Colab, you
can write, run, and share
-
Python code in your
browser, and this
-
allows you to get started
from your phone, tablet,
-
or laptop without
any configuration,
-
and you can immediately
share your code
-
with anyone with a simple link.
-
And everything you do in Colab
will be saved under your Google
-
account.
-
So you can access
them, share them,
-
just like the rest of your
files under your Google Drive.
-
If you are familiar with
the Jupyter Notebooks,
-
Google Colab is essentially
a Jupyter Notebook hosted
-
on Google servers with
additional functionalities
-
that makes it especially
popular among data science
-
artificial intelligence
communities.
-
So without further
ado, let's go ahead
-
and get started with Colab.
-
So first thing you want to do
is to search for Google Colab,
-
and it should be the one that
says colab.research.google.com.
-
Let's go into that.
-
So the very first thing you
should know about Google Colab
-
is that everything is
organized under notebooks.
-
So the first thing you see
when you come to the website
-
are basically your
recent notebooks.
-
And the first one you
will see will probably
-
be the Welcome to
Colaboratory notebook.
-
So to get started, first
thing we want to do
-
is to go ahead and
create a new notebook.
-
So the first time you
open a Colab notebook,
-
it will name it for
you with untitled 0.
-
In this case, it is 3 for me.
-
And one thing you want to do
is to rename this notebook
-
so that it's more
meaningful to us.
-
It can be something like
Colab Intro Tutorial.
-
Since many times, you will be
working with multiple notebooks
-
at a time, it can be really
helpful to appropriately name
-
your notebooks so if you
come back to it months
-
after writing it, it will be
descriptive and much easier
-
for you to know what you
were doing in that notebook.
-
And everything I
do in this notebook
-
will be saved to my Google
Drive under my Google account.
-
So when first we take a look at
Google Colab, the first thing
-
we will see, and the
major thing we will see
-
is something called a code
cell and a Play button.
-
We can go ahead and write
some Python code here
-
and it will be executed
not on our laptop,
-
but it will be run
on Google servers.
-
And currently, we are not
connected to that servers,
-
but we don't have to click
here to be connected.
-
But instead, usually
what you want to do
-
is to write some code here and
it will be automatically connect
-
to Google servers.
-
So let's write a
simple Python code.
-
Now, there are a couple of
ways I can run this code.
-
First one and the default one
is to click on this Play button.
-
-
And we just ran our
first Python code.
-
Usually, you'll want to
use keyboard shortcuts.
-
And the shortcut to
run a single cell
-
is Command Enter, which does
the same thing as clicking
-
on that Play button.
-
But most of the
time, chances are
-
you'll want to run a code
cell and create a new code
-
cell under it so
you can keep coding.
-
To do that, we will
use Shift Enter.
-
-
Which I just did.
-
Notice that there are two
types of cells I can create.
-
One of them is a code cell.
-
And this is where
we write our code.
-
Another one is a text cell.
-
So although it says
text cell, text
-
is not the only thing
we can write here.
-
Once we write some text,
using the icons above,
-
we can turn it
into bold, italic,
-
title, as well as
other features,
-
such as images or videos,
lists, and bullet points.
-
And there's actually even
a language for that called
-
markdown language.
-
And as you're getting
started with Colab,
-
it's not necessary to
learn markdown language,
-
but if you are
interested, you can
-
do that, especially later on
in your artificial intelligence
-
or data science journey.
-
For now, what you
should know is that we
-
can create code cells
that are modular,
-
and we can also use text cells
to make more explanations
-
or display images
that will be helpful
-
and maybe explain
our code better
-
with some rich text format.
-
So when we write code
inside code cells,
-
we said that it's not
running in our own laptop,
-
but it's running
at Google servers.
-
And there are actually
three types of servers
-
that Google can allocate to us,
and we can change it from here.
-
If we go to Runtime and
Change Runtime Type,
-
you will see that
you have the option
-
to have a hardware accelerator.
-
Right now, by
default, you are not
-
given a hardware accelerator,
but if you need one,
-
it's possible to have
either a GPU or a TPU.
-
So why would you need them?
-
If you're just getting started
and writing Python code
-
or simple machine learning
code that runs fast enough,
-
most likely, you'll be fine
with the default version, which
-
has no hardware
accelerator, meaning
-
that it will run on CPUs.
-
But Azure artificial
intelligence code
-
gets larger and more complex
as you do more operations.
-
That operations you make
will take more time,
-
and you will want to use some
kind of hardware accelerator.
-
And the most common hardware
accelerator is a GPU.
-
And we have access to
three GPUs within Colab.
-
One thing you will
notice is that when
-
you change the hardware
accelerator type from none
-
to GPU or a TPU, it
will basically tell you
-
that if you don't need
a hardware accelerator,
-
do not use a
hardware accelerator.
-
And this way, Google can
allocate its GPUs or TPUs
-
to people who need more
computational power.
-
For now, I'm just writing
simple Python code
-
so I can change it to none.
-
One thing you should
know is that when
-
you leave your notebook
unused for hours,
-
your notebook will be
disconnected from Google servers
-
to more efficiently
allocate its resources.
-
But do not worry.
-
When that happens,
all of your code
-
will be still safe and
nothing changed on them.
-
But you will need
to rerun your code.
-
And to do that, you can also
do it from Runtime and Run All.
-
So we talked about CPUs and
GPUs that you can connect to,
-
but there is also
another one which
-
we can access from Change
Runtime Type and Hardware
-
Accelerator, and that was TPU.
-
And TPUs are Tensor
Processing Units.
-
And do not be
scared by the name.
-
These are basically processing
units or processing chips
-
that are specifically designed
for significantly accelerating
-
artificial intelligence code.
-
And we also have free
access to them from Colab.
-
And this can be
especially useful
-
if you have larger
machine learning
-
models or artificial
intelligence models.
-
But if you are using
a smaller model,
-
you will be most likely
fine with the GPU
-
or non-hardware accelerator.
-
So until now, we just
seen Python code,
-
but we didn't see anything about
data science, machine learning,
-
or artificial intelligence code.
-
But one of the major advantages
of using Google Colab
-
is that you can't only code
Python code in the browser,
-
but all of the
major data science
-
and artificial intelligence
libraries and tools
-
come already
pre-installed in Colab.
-
And we can start using them
with import statements such as--
-
-
so in order to use TensorFlow,
NumPy, pandas, matplotlib,
-
and PyTorch, and
many more of them,
-
since they are already
pre-installed for us,
-
we can start using them with
these import statements.
-
And if you want, we can
also check their versions.
-
-
And as you can see, we're
using the latest versions
-
of the libraries, such as
using TensorFlow 2.4, which is
-
the latest one as of right now.
-
And if you're not familiar with
any of these, do not worry.
-
As you get started
with Colab, it
-
will be much easier to learn
them as you're coding them.
-
So as you're getting
started, you're not
-
required to know
what this code does
-
or what are these
libraries are about,
-
and you can learn them
one video at a time.
-
And every now and
then, you will want
-
to use libraries that
are not inside Colab.
-
And when you want
to do that, you
-
will want to prefix your code
with an exclamation mark.
-
And with that, you can install
other libraries to Colab
-
as well.
-
And when you want
to use them, you
-
can start using them with
import statements as well.
-
So as you are working
within a notebook,
-
if you want to create
a new notebook,
-
you can do that from
File and New Notebook.
-
And similar notebook actions,
such as opening the existing
-
ones, you can also do
them from here as well.
-
A lot of the times, many of the
machine learning, data science,
-
or artificial intelligence
codes are written in Colab,
-
and when you're learning from
them, one thing you want to do
-
is to save a copy in Drive.
-
And when you save
a copy in Drive,
-
you can have a copy
of that tutorial
-
and save it under your
Google Drive as well.
-
And if I do that, I
will have all the code
-
from that previous notebook,
except in this one,
-
I am not connected.
-
Which I can connect
in a second as well.
-
And I will have
this title change
-
to a copy of Colab Intro
Tutorial from Colab Intro
-
Tutorial.
-
And if I want to run
this code, you can either
-
run that code cell
by cell or you
-
can run that from
Runtime and Run
-
All, which will run all
the cells sequentially.
-
And that's one of
the reasons why
-
Colab is so popular among
data science and machine
-
learning communities.
-
And you can find
a lot of tutorials
-
are written in Colab for
ease of shareability,
-
because you can literally
share them with a single link,
-
and everyone that has an
internet connection and a Google
-
account can have
access to that code
-
and run them themselves,
as well as modifying it.
-
And if you want to
download the notebook,
-
you can also do that from here.
-
Under File, you can go
Download this notebook
-
as a ipynb file, which is
what we are using here.
-
And you can also download
it as a Python file.
-
One thing you should know
is that currently, we
-
are working with the ipynb
file, and this is the same file
-
format that you use
in Jupyter Notebooks.
-
And ipynb files are more popular
with data science and machine
-
learning because they have
additional capabilities on top
-
of Python files.
-
Some of those features
are code cells,
-
which you can save your
outputs of the code cells.
-
You can also change the
order of the code cells
-
more easily from this
up or down arrows.
-
You can delete
them, comment them,
-
and they're overall in
a more modular structure
-
that are a better fit for data
science and machine learning
-
code.
-
So these were everything
you needed to get
-
started with Google Colab.
-
As you just have seen, you can
just search for Google Colab
-
and get coding within
seconds without any setup.
-
And everything you do will be
saved under your Google account
-
and you can reach them
from your Google Drive
-
and share them
with a single link.
-
So this was it
for this tutorial.
-
If you learn better by
reading, by the way,
-
I also have this tutorial
in article format as well,
-
and I will make sure to put a
link to it in the description
-
box.
-
With that, I hope you got
some value out of this video.
-
If you want to see
more machine learning
-
and artificial
intelligence tutorials,
-
make sure to like and subscribe,
and I will see you next time.