python-3.x - Py charm 冻结图未将 8 个变量转换为常量操作
问题描述
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 完成。
解决方案
推荐阅读
- c - 可变参数函数中的默认参数提升
- image-processing - Halcon - gen_gabor 不输出 Gabor 核的功率谱
- python - 组合来自两个不同 DataFrame 的类别代码,然后将其作为列应用到每个 DataFrame
- git - Gerrit 读取制表符,在 Vim 中使用空格
- powershell - 使用 WinSCP .NET 程序集在 FTP 服务器上生成新文件和修改文件的列表
- jenkins - Jenkins 声明性管道字符串参数和建议
- reactjs - 当用户与按钮交互时,Redux 回调函数
- mysql - 通配符 LIKE 是否比 MySQL 中的多个布尔搜索更高效?
- php - 使用 CollectionType 时无法保存实体
- ruby - Capybara / RSpec 确保页面上任何地方都不存在某些东西