Getting ready

When programming a TensorFlow model, it helps to have unit tests to check the functionality of the program. This helps us because when we want to make changes to a program unit, tests will make sure those changes do not break the model in unknown ways. In this recipe, we will create a simple CNN network that relies on the MNIST data. With it, we will implement three different types of unit test to illustrate how to write them in TensorFlow.

Note that Python has a great testing library called Nose. TensorFlow also has built-in testing functions, which we will look at, that make it easier to test the value of Tensor objects without having to evaluate the values in a session.
  1. First, we need to load the necessary libraries and ...

Get TensorFlow Machine Learning Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.