Google Colab: 7 Tips & Tricks to get started

4+
Google Colab is an extremely useful tool if you want to skip setting up an environment for your deep learning, image processing, Python, etc. projects as it provides cloud-based service. This article takes you through the basics of how to get started with Google Colab as per your requirements.

Google Colab is a Jupyter notebook environment that uses cloud service for its operation. It can be used to train machine learning models, import datasets, evaluate models, etc. using just a few lines of code without using your computer’s resources heavily. It executes code on Google’s cloud servers, which means that you can use the Google hardware for your projects irrespective of what your computer possesses. 

Colab enables you to use Google’s hardware which includes GPU and TPU, without taking into account what the specifications of your machine are. It has most of the common libraries like Pandas and NLTK already installed so that the user does not have to put in that extra effort. You can use a wide variety of libraries such as Keras, PyTorch, OpenCV, etc. Colab allows you to ‘mount’ data on your Google Drive so that you don’t have to upload datasets each time you run your code. Other benefits of using Google Colab include that it enables simultaneous editing by team members on a project like a Google Docs file.

Getting Started:

  1. All you need to get started with Google Colab is a web browser. Launch the web browser of your choice and head to Google Colab
  2. To open a new notebook, go to files, and click on ‘New Notebook’. You will need to sign-in to your Google account for this so that your work is constantly saved and you can use all the resources without any issues.

Once you click on this, your workspace is ready. You can rename your file by clicking ‘Rename Notebook’ under File or by simply clicking on the name displayed above ‘File’.

Importing files to Colab project

To import a project from Github, you first need to get the project link from Github. For this, head to the Github repository that you want to clone and copy the link to clone it.

I have used the following repository: https://github.com/keras-team/keras.git

Now, head to your Colab notebook and copy the following code:

where the link after ‘clone’ is the link you copied.

Once, the cloning is successfully performed, you can see locate it in the content folder under the name of the repository.

The cloned repository can be located as such. 

Uploading dataset:

To upload a dataset to your project, the easiest way to do it is ‘mount’ your Google drive and it can be done as below:

On running the above code, you will see a link in the output section, click on the link and copy the code that you see there. Then come back to the project and paste the code where the authorization code is requested. On doing this properly, you will have successfully mounted your drive.

Now, to upload a dataset to your project, use the following code:

!wget *download link for your dataset* -p “/content/drive/My Drive/name_of_your_folder”

For example, I have uploaded the Titanic dataset using the link: https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/Titanic.csv

Using the Pandas library now, you can perform read on your imported file as follows:

Saving Project

Google Colab provides a selection of options, you can share your project on various platforms or download it in multiple formats. To do this, click on ‘File’ and your options are visible in the dropdown list.

How to install various libraries

Colab does already have a wide pool of libraries installed that are most commonly used, like Pandas. But In case you need to install any libraries you only need to run this simple command: 

pip install library_name

or 

apt-get install library_name

  1. Keras:
  1. PyTorch:
  1. OpenCV:

Likewise, you can import any libraries that you may need for your project using the above set of code.

Conclusion

In this article, we understood how to start a Google Colab project. We also covered what a wide variety of benefits Google Colab has. Importing datasets into our project and how to clone Github repositories were also covered. This explanation opens doors to a whole lot of applications that can be developed in deep learning, image processing, Python coding sector. 

close
4+

You may also like...

5 Responses

  1. Preetish Pede says:

    Amazing tricks 💯

    0
  2. Harsh says:

    Good to know about this new platform!

    0
  3. Pranav says:

    I was having problems with my setup for practicing. This article solved every doubt. Thanks a lot💯🙌🏻

    0
  1. September 22, 2020

    […] goal is to understand what GloVe implementation looks like. Before we get started, go through this Guide on How to use Google Colab so that flowing about the implementation is […]

    0
  2. October 3, 2020

    […] market for Tata Beverages. To do this, you can either use the cloud platform provided by Google; Google Colaboratory, or local services like Jupyter Notebook. So, let’s get […]

    0

Leave a Reply

Your email address will not be published. Required fields are marked *

DMCA.com Protection Status