level 3
# 保存
constant_graph = graph_util.convert_variables_to_constants(sess, sess.graph_def,['output']) # 方括号内填输出节点的名称
pb_file_path = os.path.join(ps.model_path, 'filename.pb')
with tf.gfile.FastGFile(pb_file_path, mode='wb') as f:
f.write(constant_graph.SerializeToString())
# 读取
with tf.gfile.FastGFile('filename.pb', 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
tf.import_graph_def(graph_def, name='')
image_placeholder = sess.graph.get_tensor_by_name("image_placeholder:0") # 名称都是你自己定的,自己去找就行了
ouptut = sess.graph.get_tensor_by_name("output:0")
print (sess.run(ouptut, feed_dic={})
2019年03月13日 04点03分
3