HTML5
发布时间:2022-04-26 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Tensorflow:如何将.meta,.data和.index模型文件转换为一个graph.pb文件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在tensorflow中,从头开始训练产生以下6个
文件:
我想将它们(或仅需要的)转换为一个文件graph.pb,以便能够将其转移到我的Android应用程序.
我尝试了脚本freeze_graph.py但它需要输入我还没有的input.pb文件. (我之前只提到过这6个文件).如何获得这个freezed_graph.pb文件?我看到几个线程,但没有一个为我工作.
您可以使用此简单脚
本来执行此操作.但是您必须指定
输出节点的@L_
618_10@.
@H_
607_10@import tensorflow as tf
Meta_path = 'mode
l.ckpt-22480.
Meta' # Your .
Meta file
with tf.Session() as sess:
# Restore the graph
saver = tf.
Train.import_
Meta_graph(
Meta_path)
# Load weights
saver.restore(sess,tf.
Train.la
test_checkpoint('.'))
# Output nodes
output_node_names =[n.name for n in tf.get_default_graph().as_graph_def().node]
# Freeze the graph
frozen_graph_def = tf.graph_uti
l.convert_variables_to_constants(
sess,ses
s.graph_def,output_node_names)
# Save the frozen graph
with open('output_graph.pb','wb') as f:
f.write(frozen_graph_def.
serializeTo
String())
大佬总结
以上是大佬教程为你收集整理的Tensorflow:如何将.meta,.data和.index模型文件转换为一个graph.pb文件全部内容,希望文章能够帮你解决Tensorflow:如何将.meta,.data和.index模型文件转换为一个graph.pb文件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。