tensorflow模型文件可以大致分为两种:
1.通过tensorflow.train.Saver来生成
1)保存
saver = tf.train.Saver(tf.all_variables())
saver.save(sess, 'model.ckpt')
2)加载
saver=tf.train.Saver(tf.all_variables())
save.restore(sess, 'model.ckpt')
2.通过tensorflow.GraphDef
1)保存
tf.train.write_graph(sess.graph_def, path, filename)
或者
witf tf.gfile.FastGFile(filename, 'wb') as f:
f.write(sess.graph_def.SerializeToString())
2)加载
with tf.gfile.FastGFile(filename, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
tf.import_graph_def(graph_def, name='')
暂时写这些,未完待续