tensorflow模型文件能夠大體分爲兩種:rest
1.經過tensorflow.train.Saver來生成code
1)保存it
saver = tf.train.Saver(tf.all_variables()) saver.save(sess, 'model.ckpt')
2)加載ast
saver=tf.train.Saver(tf.all_variables()) save.restore(sess, 'model.ckpt')
2.經過tensorflow.GraphDefimport
1)保存tensorflow
tf.train.write_graph(sess.graph_def, path, filename) 或者 witf tf.gfile.FastGFile(filename, 'wb') as f: f.write(sess.graph_def.SerializeToString())
2)加載file
with tf.gfile.FastGFile(filename, 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) tf.import_graph_def(graph_def, name='')
暫時寫這些,未完待續model