HOME
PRIVACY POLICY
ABOUT US

Google Colab Tricks and Tutorial for AI

Google Colab Tricks and Tutorial for AI | DEEP LEARNING ( AI ) FOR BEGINNERS AND CODERS | MULTIPLEWORDS BY PROGRAMMERS

Google Colab is a platform for Code editor which is used to practice and develop deep learning as models. Its is developed and maintain by google and is inspired by JUPYTER notebook. Many functionalities are related to JUPYTER. We will discuss here a small tutorial and tricks to get started with google Colab. It provides free GPU and TPU's

GETTING STARTED

When ever you login through your google account and open goolge COLAB it create a virtual Linux server for your account which contains 300 Gb storage with 12 GB of GPU and 12 GB of RAM which you used for your development purpose. It contains all main python library installed in it. It contains all major deep learning frameworks also. you just need to import in your notebook.

STRUCTURE

It is consist of cells and each cell has a state. It is developed by two types of cell one is code cell and one is text cell. In code cell you can write codes and in text cell you can explain that code which is not executable.

google colab code cell text cell creation | DEEP LEARNING ( AI ) FOR BEGINNERS AND CODERS | MULTIPLEWORDS BY PROGRAMMERS

SETTING

AUTO SAVING OUTPUT

You can set your preference of auto serving of output as you got only 20 moles limit from google colab of your notebook and output in crore that size.

CHANGE COMPUTATION SETTING

You can change computation setting to CPU , GPU and TPU's as your preference.

CHANGE COMPUTATION SETTING In google colab to GPU OR TPU | DEEP LEARNING ( AI ) FOR BEGINNERS AND CODERS | MULTIPLEWORDS BY PROGRAMMERS

INPUT

KAGGLE

You can import your data set from Kaggle by first creating your API token from your kaggle account and then downloading at your PC's then run following code in a cell to upload than in google Colab.


from google.colab import files


uploaded = files.upload()


for fn in uploaded.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded[fn])))
  
# Then move kaggle.json into the folder where the API expects to find it.
!mkdir -p ~/.kaggle/ && mv kaggle.json ~/.kaggle/ && chmod 600 ~/.kaggle/kaggle.json


Now go to competition. Lets say dog vs CAT go in data and copy API download and paste in google colab cell your data will be downloaded.

LOCAL UPLOAD

You can upload data from your machine by code cell and UI interaction also through code cell copy paste following command and run it and upload your file.

WEBSITE DOWNLOAD

You can download data through any website download liks using !wget website link which download data/content /path


!wget 'webiste link'

GOOGLE DRIVE

You can mount google drive directly to your notebook and access any file available there. Run following code to mount google drive /content/drive/........your drive.....


from google.colab import drive
drive.mount('/content/gdrive')

ONE DRIVE/ DROP BOX

You can click on share button in both cloud platform which generate link. Just run ! Wget link to download that content to your notebook

COMMAND

Google Colab provides facilities to access different options through shortcut commands you can also access shell command from google Colab by just writing '!' before shell command. Colab consider '!' as after this everything should be seen in shell command. Following shortcuts are highly used during programming.

RUN CELL - Ctrl+Enter

DELETE CELL - Ctrl+M+D

ADD CELL ABOVE - Ctrl+M+A

ADD CELL BELOW - Ctrl+M+B

? {function} - To check documentation of this any function

?? {function} - To check full code and documentation of this function

CLEAR OUTPUT - Ctrl+M+O

You can create and find more shortcuts at settings.

DEBUGGING

You can debug your python code using pdb and PYTHON just import pdb and write pdb.set_trace() where you want break point and excution will stop there you can use pdb commands to go into further details.

OUTPUT

KAGGLE SUBMISSION

You can submit your submission file directly to kaggle by follow submission API from kaggle. You can just copy paste submission API from kaggle on command line with proper paths of your submission file and run that cell.

GOOGLE OUTPUT

To save output to google drive you have to first mount google drive to your notebook and then just save. It will save to google Colab.

DOWNLOAD DIRECTLY

You can download directly using command and UI in your local machine.

PROS

Limitation which I found on google is that it does not offer plugin integration which was given by JUPYTER. Auto will not work if you didn't the cell. You can only same up to 20Mb file and it only offer 12 hours simultaneous use which sometimes is problematic.

LOCAL UPLOAD In Google colab | DEEP LEARNING ( AI ) FOR BEGINNERS AND CODERS | MULTIPLEWORDS BY PROGRAMMERS

CONCLUDE

In this tutorial we have seen some techniques to use google colab. It is really handy and worth using tool for deep learning practice. If you have any query or feedback or need any help regarding boiler code of any topic , you can freely ask in comments. I would really love to help you

taher AI Professional

Related Posts