1. tensorflow模型文件打包成PB文件
import tensorflow as tf
from tensorflow.python.tools import freeze_graph
with tf.Graph().as_default():
with tf.device("/cpu:0"):
config = tf.ConfigProto(allow_soft_placement=True)
with tf.Session(config=config).as_default() as sess:
model = Your_Model_Name()
model.build_graph()
sess.run(tf.initialize_all_variables())
saver = tf.train.Saver()
ckpt_path = "/your/model/path"
saver.restore(sess, ckpt_path)
graphdef = tf.get_default_graph().as_graph_def()
tf.train.write_graph(sess.graph_def,"/your/save/path/","save_name.pb",as_text=False)
frozen_graph = tf.graph_util.convert_variables_to_constants(sess,graphdef,['output/node/name'])
frozen_graph_trim = tf.graph_util.remove_training_nodes(frozen_graph)
f