This content originally appeared on Level Up Coding - Medium and was authored by Erich Hohenstein
Intro to Google Colab
Have you ever wanted to jump into the AI frenzy and work with Neural Networks and all that hot Data Science stuff but you are stuck with your old potato PC? Let’s be fair… Buying a new PC with the special hardware to train Neural Networks is quite expensive for anyone. Especially today with all those Crypto miners stocking up all the precious GPUs. Cry no more my sweet children! There is a solution that would even let you train a Neural Network on a Raspberry Pi! Introducing: Google Colab

- What is Google Colab?
- How to create a Google Colab Notebook
- Uploading your data
- Installing special libraries
- Getting those precious GPUs
- Sharing is Caring
- Final Comments
What is Google Colab?
Google Colab was created by…guess who…Apple? No….Google! They created Colab to give free access to virtually anyone to the hardware needed to do Deep Learning. With Google Colab you have access to Server CPUs, State of the Art GPUs and TPUs for free! and the only two things you need is Internet access and a Google account. It uses the familiar environment of Notebooks, so if you like working with Jupyter, you will feel right at home. Did I mention is free?

How to create a Google Colab Notebook
To get started with Google Colab, we will go into our Google Drive and create a new folder for our project. Then we will create a new Google Colab notebook which will open a new window right into the notebook environment.


Uploading your data
Now that we have a new Colab Notebook and we are ready to work, the next task is getting your data. There are two ways to do this. One is to upload your data straight from your computer to your Colab session and the other is to Mount your Google Drive to the Colab session. The later option basically means giving Colab permission to access your Google Drive and read data directly from there.
- Direct Upload
from google.colab import files
uploaded = files.upload()
This command will open a window so you can select and upload your files. Once they finish uploading we can read them, for instance into a dataframe like this.
df = pd.read_csv(io.BytesIO(uploaded['netflix.csv']))
- Mount Drive
from google.colab import drive
drive.mount('/content/drive')
Once the drive is mounted, we read our files by giving the full path within Google Drive.
df = pd.read_csv('/content/drive/MyDrive/Blog/00 Data/netflix.csv')
Something important to mention is that Colab works with sessions, this means there are limits to how long you leave the server idle and how long can you leave it training your model. For this reason I recommend having your datasets and models on your Google Drive and mounting it to your Colab session, this way you don't have to manually upload all your files each time you start a new session.
Installing special libraries
Google Colab comes preinstalled with all the common Data Science libraries such as Pandas, Matplotlib, numpy, etc. If you want to install other libraries you can do as follows.

Getting those precious GPUs

Each time you create a new Google Colab notebook, the GPUs are not enabled by default. You can actually check this with:
!nvidia-smi
If we run this command, we will see no GPUs. To activate the GPUs we do as follows.

Running the command again we get.


Sharing is Caring
After working on your model and notebook, you probably want to share it or add it to your Github repository. There are 2 ways for exporting and sharing your notebooks:
- Download your script as .ipynb, .py, or even .html

- Connect to your Github repository

You can check this notebook on my Github:
GitHub - erichho/02-Intro-to-Google-Colab
Or in my Google Drive:
Final Comments
Jumping into the Artificial Intelligence hype has never been this easy. Google is certainly pushing forward for this technology to become more and more mainstream. As a Data Scientist, I see that this is a great opportunity to learn about Deep learning, Data Science, even Python using Google Colab without worrying about hardware, costs and programming environments. So, go ahead…get your data together and create the next AI that will change the world!
Google Colab — What is it? How to use it? and why should I care? was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Erich Hohenstein

Erich Hohenstein | Sciencx (2022-04-15T14:13:42+00:00) Google Colab — What is it? How to use it? and why should I care?. Retrieved from https://www.scien.cx/2022/04/15/google-colab-what-is-it-how-to-use-it-and-why-should-i-care/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.