Hidden features of Google Colaboratory


When working with deep learning some of the major stoppers are training data and computation resources. Google provides free solution for computation resources with Colaboratory, Google’s free environment which have GPU. Colaboratory provides online jupyter notebook where you can select GPU as back-end server. You can read more about the Colab here.

Here I will add some of the features which might be helpful for you in some scenarios.

Upload files directly from Colab

from google.colab import files

Download trained models

from google.colab import files
files.download("File Name")

Suppose you want to download a trained Keras model.

model.save('trained_model.h5') #where model is already trained
from google.colab import files

You can use also python to load data form web and directly work on it. The benefit of it will be that your single python notebook will also work in all other notebook environments (with disadvantage of downloading the dataset for each environment).

from urllib.request import urlretrieve
import os
from zipfile import ZipFile

def download(url, file):
if not os.path.isfile(file):
print("Download file... " + file + " ...")
print("File downloaded")

download('Url of the file','Name of the file to be saved')
print("All the files are downloaded")
#If the downloaded file is a zip file than you can use below function to unzip it.
print('Data extracted')
with ZipFile(dir) as zipf:

Executing command

!pip install — upgrade tensorflow

I hope that this helps you somewhere. If you know some other interesting feature of Colab then please comment below and let us know.

Autonomous Vehicle Engineer. #FutureAI #LearningAI

Autonomous Vehicle Engineer. #FutureAI #LearningAI