Training with Colab

To train with Colab, you'll need to have a good Internet connection and be able to leave your browser running with the Colab webpage open for several hours. Make sure your laptop battery is charged before you start this guide!

Getting Started

To get started, click here to open our notebook in Colab.

When you click the link, it should take you to a page that looks like this:

biometric_guide-large.png
The notebook looks like this when you first open it.

Configuring your Colab instance

To get started, move your mouse cursor over the [ ] box to the left of the first code snippet, underneath the Configure training header. It will change to a "Play" icon. Click on this icon.

At this point, you may be prompted to sign in to your Google account. You'll need to sign in before you can continue with this guide.

What should happen?

After typically 20 seconds or so, you'll see the notebook come to life. The previous output will vanish and you'll see it replaced with the result of running on your new runtime (see the section titledAside below for more about what a runtime is).

When you see the following output, you know you've finished this step. You can open another copy of the notebook and compare it to our previous run, just to make sure it looks correct.

Training these words: ['yes', 'no']
Training steps in each stage: [15000, 3000]
Learning rate in each stage: ['0.001', '0.0001']
Total number of training steps: 18000

Aside: Behind the Scenes

Each time you open a Colab notebook, Google lets you temporarily use a computer in their datacenter to run your code. This computer is running a program called the runtime, which lets you play around with TensorFlow without having to worry about how fast your computer and without needing to buy an expensive graphics card.

When you close your Colab notebook, Google replaces your runtime with a brand new one, and releases your machine to someone else. This means that each time you come back, you'll need to set up the machine from scratch.

The first few cells in the notebook do just that.

Connect to Google Drive

As mentioned in the last Aside section, the runtime (along with any files created) is lost when you close your browser tab. We'll need to find somewhere more permanent to store our trained model. Fortunately, Google provides a handy way to connect your Google Drive to the notebook. It appears just like a regular folder on the Colab runtime.

The next cell will connect your Google Drive to the Colab. You'll need to authorize the connection in a new browser tab. First, run the next cell, titled Connect to Google Drive. You should see something like this appear:

biometric_drive.png
You'll need to authorize Colab to use your Google Drive. We use this to store files more permanently, since Colab only provides temporary storage.

Click the URL, which will open a new browser tab. Go through the steps to select the Google account you want to use, and allow access to the Google Drive File Stream app. This was written by Google to work with Colab.

When you've successfully authorized it, you'll see this screen (the code in this image is blurred). Copy the code (or click the helpful copy button to the right), switch back to the Colab tab, and paste the code into the text box below the Enter your authorization code text.

biometric_drive-auth.png
When you reach this screen, you've authorized Colab to use your Google Drive. Now, copy and paste the code back into the notebook.

Training the model

Now you're ready to train your speech recogntion model! Run the next few cells, titled Install Dependencies and Download Tensorflow.

If you want to visualize training while it's in progress, run the Optional: Visualize graph and training rate cell. This isn't required, though.

Finally, run the Create trained model cell. This will run for several hours, and you can't close your browser tab--so, be sure you can leave your computer running for a while.

Model Output

You can find your model output on your Google Drive, in a folder called speech-recognition. You should see something like the following screen.

This guide was first published on Jul 17, 2019. It was last updated on Jul 17, 2019. This page (Training with Colab) was last updated on Feb 20, 2020.