我想下载inception_resnet_v2并恢复它并为C#tensorflow程序制作一个冻结的模型文件。(。PB)。
参考:How to restore tensorflow inceptions checkpoint file (ckpt)?
Python代码:
import tensorflow as tf
slim = tf.contrib.slim
from inception_resnet_v2 import inception_resnet_v2, inception_resnet_v2_arg_scope
height = 299
width = 299
channels = 3
X = tf.placeholder(tf.float32, shape=[None, height, width, channels])
with slim.arg_scope(inception_resnet_v2_arg_scope()):
logits, end_points = inception_resnet_v2(X, num_classes=1001,is_training=False)
saver = tf.train.Saver()
sess = tf.Session()
saver.restore(sess, "./inception_resnet_v2_2016_08_30.ckpt")
tf.train.write_graph( sess.graph_def, "./pb", 'inception_resnet_v2_2016_08_30.pb', as_text=True)
inception_resnet_v2_2016_08_30.ckpt [226MB]
inception_resnet_v2_2016_08_30.pb [6MB]
输出文件不正确。
如何获取完整的.pb文件?
制作一个冻结的模型文件参考: github.com/migueldeicaza/TensorFlowSharp/issues/85#issuecomment-313590825
命令:
python .\Python\Python35\Lib\site-packages\tensorflow\python\tools\freeze_graph.py -- input_graph=.\inception_resnet_v2_2016_08_30.pb --input_checkpoint=.\inception_resnet_v2_2016_08_30.ckpt --output_node_names=Output/Predictions,Output/Loss --output_graph=inception_resnet_v2_2016_08_30_out.pb
错误:AssertionError:输出/预测不在图中