[go: up one dir, main page]

0% found this document useful (0 votes)
44 views8 pages

Practical 1

Google Colab, or Colaboratory, is a free cloud-based Jupyter notebook environment that allows users to write and execute Python code with zero configuration and access to free GPUs. It supports various machine learning libraries, enables easy sharing and collaboration, and integrates with Google Drive for storage. While it offers advantages like pre-built libraries and no infrastructure setup, it has limitations such as the need to install specific libraries and challenges with larger datasets.

Uploaded by

shreyptl2981
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views8 pages

Practical 1

Google Colab, or Colaboratory, is a free cloud-based Jupyter notebook environment that allows users to write and execute Python code with zero configuration and access to free GPUs. It supports various machine learning libraries, enables easy sharing and collaboration, and integrates with Google Drive for storage. While it offers advantages like pre-built libraries and no infrastructure setup, it has limitations such as the need to install specific libraries and challenges with larger datasets.

Uploaded by

shreyptl2981
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Practical 1

Aim : Explore any one machine learning tool. (like Weka,


Tensorflow, Scikit-learn, Colab, etc.)
Google Colab
Google is quite aggressive in AI research. Over many years, Google developed AI framework
called TensorFlow and a development tool called Colaboratory. Today TensorFlow is open-
sourced and since 2017, Google made Colaboratory free for public use. Colaboratory is now
known as Google Colab or simply Colab.

What is Colab?
Colab, or "Colaboratory", allows you to write and execute Python in your browser, with
 Zero configuration required
 Access to GPUs free of charge
 Easy sharing

If you have used Jupyter notebook previously, you would quickly learn to use Google Colab.
To be precise, Colab is a free Jupyter notebook environment that runs entirely in the cloud.
Most importantly, it does not require a setup and the notebooks that you create can be
simultaneously edited by your team members - just the way you edit documents in Google
Docs. Colab supports many popular machine learning libraries which can be easily loaded in
your notebook.

What Colab Offers You?


As a programmer, you can perform the following using Google Colab.
 Write and execute code in Python
 Document your code that supports mathematical equations
 Create/Upload/Share notebooks
 Import/Save notebooks from/to Google Drive
 Import/Publish notebooks from GitHub
 Import external datasets e.g. from Kaggle
 Integrate PyTorch, TensorFlow, Keras, OpenCV
 Free Cloud service with free GPU
How to use colab ?
Note − As Colab implicitly uses Google Drive for storing your notebooks, ensure that you are
logged in to your Google Drive account before proceeding further.

Step1 − Open the following URL in your browser − https://colab.research.google.com Your


browser would display the following screen (assuming that you are logged into your Google
Drive) −

Step 2 − Click on the NEW PYTHON 3 NOTEBOOK link at the bottom of the screen. A new
notebook would open up as shown in the screen below.

Setting Notebook Name


By default, the notebook uses the naming convention UntitledXX.ipynb. To rename the
notebook, click on this name and type in the desired name in the edit box as shown here −

We will call this notebook as MyFirstColabNotebook. So type in this name in the edit box
and hit ENTER. The notebook will acquire the name that you have given now.

Entering Code
You will now enter a trivial Python code in the code window and execute it.
Enter the following two Python statements in the code window –
import time
print(time.ctime())

Executing Code
To execute the code, click on the arrow on the left side of the code window.

After a while, you will see the output underneath the code window, as shown here −
Mon Jun 17 05:58:40 2019
You can clear the output anytime by clicking the icon on the left side of the output display.
Adding Code Cells
To add more code to your notebook, select the following menu options –
Insert / Code Cell
Alternatively, just hover the mouse at the bottom center of the Code cell. When
the CODE and TEXT buttons appear, click on the CODE to add a new cell. This is shown in the
screenshot below −

A new code cell will be added underneath the current cell. Add the following two statements
in the newly created code window −
time.sleep(5)
print (time.ctime())
Now, if you run this cell, you will see the following output −
Mon Jun 17 04:50:27 2019
Certainly, the time difference between the two time strings is not 5 seconds. This is obvious
as you did take some time to insert the new code. Colab allows you to run all code inside
your notebook without an interruption.
Run All
To run the entire code in your notebook without an interruption, execute the following
menu options −
Runtime / Reset and run all…
It will give you the output as shown below −

Note that the time difference between the two outputs is now exactly 5 seconds.
The above action can also be initiated by executing the following two menu options −
Runtime / Restart runtime…
or
Runtime / Restart all runtimes…
Followed by
Runtime / Run all
Study the different menu options under the Runtime menu to get yourself acquainted with
the various options available to you for executing the notebook.

Changing Cell Order


When your notebook contains a large number of code cells, you may come across situations
where you would like to change the order of execution of these cells. You can do so by
selecting the cell that you want to move and clicking the UP CELL or DOWN CELL buttons
shown in the following screenshot −

You may click the buttons multiple times to move the cell for more than a single position.

Deleting Cell
During the development of your project, you may have introduced a few now-unwanted
cells in your notebook. You can remove such cells from your project easily with a single click.
Click on the vertical-dotted icon at the top right corner of your code cell.

Click on the Delete cell option and the current cell will be deleted.
Now, as you have learned how to run a trivial notebook, let us explore the other capabilities
of Colab.
Saving to Google Drive
Colab allows you to save your work to your Google Drive. To save your notebook, select the
following menu options −
Why do we need Google Colab?
Colab gives you free access to computing infrastructure to test and execute your code. Like
many of Google's products, there is a free tier and paid options. The free version of Colab is
for students, hobbyists, and small experimental projects.

Avaantages :
 Pre-built with lots of python library
 Quick Start of python learning
 No infra setup required
 No charges for GPU usage
 Can run your code for 24 hrs without interruptions but not more than that
 Your notebooks is saved in google drive only

Disadvantages :
 Need to install all specific libraries which does not come with standard python
Google Drive is your source and target for Storage, there are other like local
 Google provided the code to connect and use with google drive but that will not
work with lots of other data format
 Google Storage is used with current session, so if you have downloaded some file
and want to use it later, better save it before closing the session.
 Difficult to work with BIGGER datasets as you have to download and store them in
Google drive

You might also like