[Google Colab] Developer guide for Google Colab

What is Google CoLab ?

Google Colaboratory is a promising machine learning research platform and free cloud service hosted by Google to encourage Machine Learning and Artificial Intelligence research. Now it supports free GPU!
The most important feature that distinguishes CoLab from other cloud services is totally free.

Hình ảnh có liên quan

Overview
Colaboratory supports Python 2.7 and Python 3.6, so you can improve your Python programming language coding skills.
Deploy deep learning model using popular libraries such as Tensorflow, Keras, Numpy, OpenCV,….
Colaboratory is a research tool for machine learning education and research. It’s a Jupyter notebook environment that requires no setup to use. Jupyter is the open source project on which Colaboratory is based. Colaboratory allows you to use and share Jupyter notebooks with others without having to download, install, or run anything on your own computer other than a browser.

Steps to start work on Google CoLab

  1. View the “Hello, Colaboratory”
    Visit this link: https://colab.research.google.com/
    Click Hello, Colaboratory or go to this link: https://colab.research.google.com/notebooks/welcome.ipynb
Hello, Colaboratory

Now, you can see the useful document in Getting Started such as:

2. Creating & Setting Colab Notebook
Creating Colab Notebook
Because Colab is working on your own Google Drive, we must create or upload notebook to Google Drive.
Firstly, go to Google Drive and creat folder, then “Right Click” → “More” → Colabroratory.
Rename notebook with “notebookname.ipynb” because “.ipynb” is jupyter notebook.

After that, we open this notebook.

So, we will setting Colab Notebook
“Edit” → “Notebook setting”
You can choose Runtime Type and Harware Accelerator. For this example, I choose Python 3 with no Harware Accelertor.

3. Running Colab Notebook
I will demo basic code in nodebook.
You can copy this source code:

import numpy as np

# Create the following rank 2 array with shape (3, 4)
# [[ 1 2 3 4]
# [ 5 6 7 8]
# [ 9 10 11 12]]
a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])

# Two ways of accessing the data in the middle row of the array.
# Mixing integer indexing with slices yields an array of lower rank,
# while using only slices yields an array of the same rank as the
# original array:
row_r1 = a[1, :] # Rank 1 view of the second row of a
row_r2 = a[1:2, :] # Rank 2 view of the second row of a
print(row_r1, row_r1.shape) # Prints "[5 6 7 8] (4,)"
print(row_r2, row_r2.shape) # Prints "[[5 6 7 8]] (1, 4)"

# We can make the same distinction when accessing columns of an array:
col_r1 = a[:, 1]
col_r2 = a[:, 1:2]
print(col_r1, col_r1.shape) # Prints "[ 2 6 10] (3,)"
print(col_r2, col_r2.shape) # Prints "[[ 2]
# [ 6]
# [10]] (3, 1)"

For running this code, you can click “Run cell” or “Shift” + “Enter”

  • Note: if you want to install library in python you should use this command:
    !pip install <library_name> and run this command
    For instance, !pip install numpy or !pip install tensorflow

These are some useful resources for training the model and using GPU:
TensorFlow with GPU
TensorFlow with TPU
Machine Learning Crash Course: Intro to Pandas & First Steps with TensorFlow
Google Colab Free GPU Tutorial
Colab an easy way to learn and use tensorflow

--

--

--

blog.hoduchieu.tech

Love podcasts or audiobooks? Learn on the go with our new app.

Supervised Learning vs Unsupervised Learning

Review — Temporal Modeling Approaches for Large-scale Youtube-8M Video Understanding (Video…

Scribble Stadium — Bridging the Analog and Digital

Forward and Backpropagation in GRUs — Derived | Deep Learning

ML workflow with Airflow, MLflow and SageMaker

How To Create An MVP for Mental Health With Machine Learning

Week 4 — Copy Move Forgery Detection

Review — F-RNN: No-Reference Video Quality Assessment using Recurrent Neural Networks

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ho Duc Hieu

Ho Duc Hieu

blog.hoduchieu.tech

More from Medium

The Bachelorette: Does Twitter have what it takes to predict a winner?

Data x Style (Python Code)

Function approximation with Tensorflow

Billboard to Spotify in Python