I am using a graph file which i doesn't know the name of the variables on this graph model
this files i have :-
- training_model_saved_model.pb
- variables
- training_model_variables_variables.data-00000-of-00001
- training_model_variables_variables.index
i started by this code but i can't get the variable names so i can set them
import tensorflow as tf
import sys
from tensorflow.python.platform import gfile
from tensorflow.core.protobuf import saved_model_pb2
from tensorflow.python.util import compat
with tf.Session() as sess:
model_filename ='training_model_saved_model.pb'
with gfile.FastGFile(model_filename, 'rb') as f:
data = compat.as_bytes(f.read())
sm = saved_model_pb2.SavedModel()
sm.ParseFromString(data)
#print(sm)
if 1 != len(sm.meta_graphs):
print('More than one graph found. Not sure which to write')
sys.exit(1)
graph_def = tf.GraphDef()
#graph_def.ParseFromString(sm.meta_graphs[0])
x,y,z = tf.import_graph_def(sm.meta_graphs[0].graph_def,return_elements=['data/inputs:0',
'output/network_activation:0',
'data/correct_outputs:0'],
name='')
LOGDIR='Log_dir'
train_writer = tf.summary.FileWriter(LOGDIR)
train_writer.add_graph(sess.graph)
error return is expected
Traceback (most recent call last):
File "execute_model.py", line 24, in <module>
'data/correct_outputs:0'],name='')
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/importer.py", line 526, in import_graph_def
'Requested return_element %r not found in graph_def.' % name)
ValueError: Requested return_element 'data/inputs:0' not found in graph_def.
any help , thanks in advance