From the course: Building and Deploying Deep Learning Applications with TensorFlow

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Save and load trained models

Save and load trained models - TensorFlow Tutorial

From the course: Building and Deploying Deep Learning Applications with TensorFlow

Start my 1-month free trial

Save and load trained models

- [Instructor] So far, we've built and trained the model. Now, let's learn how to save that model to a file, so that we can reuse it later. Open up model_checkpoints.py. Here, we have the code to define and train the neural network. But, after the file runs, the neural network isn't saved anywhere. Let's go down to Line 95. To save it, we first need to create a tf.train.Saver object. Let's put it here, under the graph definition, but before the training loop. Tf .train .Saver. This is the object we'll use to save the model. Now, at the very bottom of the code, way down on Line 150, let's go down there. We can save the model. To save the model, we just call saver.save and pass in the session and the file name. So, we'll call saver.save. We'll pass in the session and then the file name where we want to save it. I'll use log/trained_model.ckpt. These files are called checkpoint files, so they're usually named with a .ckpt file name extension, but that's not required. Then, here on the…

Contents