py魅力冻结图未将8变量转换为常量操作

时间:2018-10-05 09:28:32

标签: python-3.x tensorflow

import tensorflow as tf

from tensorflow.python.tools import freeze_graph,optimize_for_inference_lib

# Saving the graph as a pb file taking data from pbtxt and ckpt files and providing a few operations
freeze_graph.freeze_graph('advanced_mnist.pbtxt',
                          '',
                          True,
                          'advanced_mnist.ckpt',
                          'h_readout1',
                          'save/restore_all',
                          'save/Const:0',
                          'frozen_advance_mnist.pb'
                          ,True,
                          '')
# Read the data form the frozen graph pb file

input_graph_def = tf.GraphDef()
with tf.gfile.Open('frozen_advance_mnist.pb','rb') as f:
    data = f.read()
    input_graph_def.ParseFromString(data)
# Optimize the graph with input and output nodes
output_graph_def = optimize_for_inference_lib.optimize_for_inference(input_graph_def,['x_input','keep_prob'],['h_readout1'],tf.float32.as_datatype_enum)
# Save the optimized graph to the optimized pb file
f = tf.gfile.FastGFile('optimized_advanced_mnist.pb','w')
f.write(output_graph_def.SerializeToString())

我尝试运行输入和输出,但是文件没有将变量转换为任何常量操作,而是仅以退出代码0完成处理。

0 个答案:

没有答案