Predicting Sequences Using TensorFlow

1.5 hours
  • 4 Learning Objectives

About this Hands-on Lab

In this lab, you will build a sequence prediction model using TensorFlow that will forecast the amount of precipitation. You will be performing the entire model creation process, from retrieving the data and formatting it properly, to designing a model architecture and training it to meet a desired metric score.

This lab is designed to be used as a practice exam to test your skills in preparation for the TensorFlow Developer Certificate, and thus is a very challenging exercise.

Before beginning this lab, you should have PyCharm installed on your local computer. Additionally, you should have installed all packages required by the TensorFlow Developer Certificate exam.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Retrieve and Load the Monthly Precipitation Data
  1. View the data to understand how to parse it.
  2. Retrieve the Monthly Precipitation JSON data.
  3. Load the JSON data into the program.
  4. Parse the dictionary into time steps and precipitation values.
Normalize, Split, and Window the Dataset
  1. Review the model expectations to understand how to prepare your data.
  2. Normalize all of the data.
  3. Split the data into training, validation, and testing datasets.
  4. Convert the raw sequences into windowed sequences.
Build and Train a Model to Predict the Precipitation
  1. Review the model expectations to understand how your model should accept and output data.
  2. Create an appropriate neural network model using Keras.
  3. Compile your model with an appropriate loss function for the problem type and data. Include any metrics you want to use to evaluate your model.
  4. Train your model to reach the desired performance. Remember to capture your history!
  5. Save the model.
Evaluate Your Model with the Test Data
  1. Generate model statistics on the test data. Ensure you’ve met or exceeded the desired performance metric.
  2. Plot the predictions to see how well the model works.
  3. Plot the values from your training history.

Additional Resources


You need to build a model to predict the total amount of monthly precipitation across the United States.

We will be using data from NOAA's Climate at a Glance: National Time Series. This dataset is available as a Monthly Precipitation JSON file.

Use the data from 1900 to 1999 (inclusive) in 6-month windows to train your model.

The model will be tested against the data from 2000 to 2020, min-max normalized against the entire dataset from 1900 to 2020.

The model should output a prediction of precipitation in normalized inches. Your model should achieve below a 0.13 Root Mean Squared Error on the test data.

Lab Goals

  1. Retrieve and load the monthly precipitation data.
  2. Normalize, split, and window the dataset.
  3. Build and train a model to predict the precipitation.
  4. Evaluate your model with the test data.

As this is practice for the exam, you should attempt to solve the tasks on your own before checking the lab guide or the solution videos. Test your skills and see what areas you need to review.

Logging In To the Lab Environment

No environment is provided for this lab. This lab, which is a practice exam for the TensorFlow Developer Certificate, is meant to be completed in PyCharm running on your own hardware. It is important that you complete this lab on your own computer so you know how long different model architectures will take you to train, which will help you budget your time during the exam.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?