From a1e0eb6fa5b32d34fa7434e13d1bfb0ac3b9daf7 Mon Sep 17 00:00:00 2001 From: haabhi Date: Fri, 16 Nov 2018 03:33:10 +0545 Subject: [PATCH] Updated documentation to use .meta files --- .../code_template/tensorflow_sample.py | 4 ++-- tutorials/tensorflow_prototxt_usage.md | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/example/tensorflow/code_template/tensorflow_sample.py b/example/tensorflow/code_template/tensorflow_sample.py index 5248e1749..4c0e1c3fb 100644 --- a/example/tensorflow/code_template/tensorflow_sample.py +++ b/example/tensorflow/code_template/tensorflow_sample.py @@ -11,9 +11,9 @@ # Read the protobuf text and build a tf.GraphDef with open(model_file_name, 'r') as model_file: model_protobuf = text_format.Parse(model_file.read(), - tf.GraphDef()) + tf.MetaGraphDef()) # Import the GraphDef built above into the default graph -tf.import_graph_def(model_protobuf) +tf.train.import_meta_graph(model_protobuf) # You can now add operations on top of the imported graph diff --git a/tutorials/tensorflow_prototxt_usage.md b/tutorials/tensorflow_prototxt_usage.md index 8035821d9..772692ec5 100644 --- a/tutorials/tensorflow_prototxt_usage.md +++ b/tutorials/tensorflow_prototxt_usage.md @@ -6,34 +6,34 @@ In order to export a Tensorflow model from Fabrik: 2. A drop-down list should appear. Select Tensorflow. - * This should download a pbtxt file to your computer. + * This should download a ```.meta``` file to your computer. -3. Rename the file to ```model.pbtxt```. +3. Rename the file to ```model.meta```. -4. Load the model from the ProtoBuf file using the following code: +4. Load the model from ```model.meta``` using the following code: ``` import tensorflow as tf from google.protobuf import text_format # read the graphdef from the model file - with open('model.pbtxt', 'r') as model_file: + with open('model.meta', 'r') as model_file: model_protobuf = text_format(model_file.read(), - tf.Graphdef()) + tf.MetaGraphDef()) # import the graphdef into the default graph - tf.import_graph_def(model_protobuf) + tf.train.import_meta_graph(model_protobuf) ``` ### Code template -[The code template](../example/tensorflow/code_template/tensorflow_sample.py) loads the model from a pbtxt file into the default graph. Additional operations like layers and optimizers can be then built onto the graph as required. +[The code template](../example/tensorflow/code_template/tensorflow_sample.py) loads the model from a ```.meta``` file into the default graph. Additional operations like layers and optimizers can be then built onto the graph as required. To run the code, run: ``` -python tensorflow_sample.py model.pbtxt +python tensorflow_sample.py model.meta ``` -Replace ```model.pbtxt``` with the model file that you want to use. +Replace ```model.meta``` with the model file that you want to use.