How to do it...

  1. When running a TensorFlow program, we may want to check that no other graph session is already in memory, or that the graph session is cleared after debugging a program. We can accomplish this by using the following command line:
from tensorflow.python.framework import ops 
ops.reset_default_graph() 
  1. When dealing with text (or any data pipeline), we need to be sure that we save how we process the data, so that we can process future evaluation data the same way. If we are dealing with text, for example, we need to be sure we can save and load the vocabulary dictionary. The following code is an example of how to save the vocabulary dictionary with the JSON library:
import json word_list = ['to', 'be', 'or', 'not', 'to', 'be'] ...

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.