python - restoring weights of an already saved Tensorflow .pb model -
i have seen many posts restoring saved tf models here, none answer question. using tf 1.0.0
specifically, interested in seeing weights inceptionv3
model publicly available in .pb
file here. managed restore using small chunk of python code , can access graphs high-level view in tensorboard
:
from tensorflow.python.platform import gfile inception_log_dir = '/tmp/inception_v3_log' if not os.path.exists(inception_log_dir): os.makedirs(inception_log_dir) tf.session() sess: model_filename = './model/tensorflow_inception_v3_stripped_optimized_quantized.pb' gfile.fastgfile(model_filename, 'rb') f: graph_def = tf.graphdef() graph_def.parsefromstring(f.read()) _= tf.import_graph_def(graph_def,name='') writer = tf.train.summarywriter(inception_log_dir, graph_def) writer=tf.summary.filewriter(inception_log_dir, graph_def) writer.close()
however, failed access layers' weights.
tensors= tf.import_graph_def(graph_def,name='')
returns empty, if add arbitrary return_elements=
. have weights @ all? if yes, appropriate procedure here? thanks.
use code print tensor's value :
with tf.session() sess: print sess.run('your_tensor_name')
you can use code retrieve tensor names:
op = sess.graph.get_operations() m in op : print(m.values())
Comments
Post a Comment