[英]Is saved_model.pb from keras.models.save_model the same with tensorflow freeze_graph output .pb file?
After a model is trained in keras, I used to apply tf.compat.v1.graph_util.convert_variables_to_constants
or freeze_graph.py
to freeze model and output .pb file. After a model is trained in keras, I used to apply tf.compat.v1.graph_util.convert_variables_to_constants
or freeze_graph.py
to freeze model and output .pb file. Like this:像这样:
output_graph_def = tf.compat.v1.graph_util.convert_variables_to_constants(sess, input_graph_def, output_node_names)
with tf.gfile.GFile('model.pb', "wb") as f:
f.write(output_graph_def.SerializeToString())
Recently, I find tf.compat.v1.graph_util.convert_variables_to_constants
is labeled with: Warning: THIS FUNCTION IS DEPRECATED
.最近,我发现tf.compat.v1.graph_util.convert_variables_to_constants
标有: Warning: THIS FUNCTION IS DEPRECATED
。
So I'm looking for a updated method of generate .pb
file.所以我正在寻找一种生成.pb
文件的更新方法。 I find this: keras.models.save_model()
to save model and output dir contains:我发现这个: keras.models.save_model()
保存 model 和 output 目录包含:
assets saved_model.pb variables资产 saved_model.pb 变量
I'm not sure if this saved_model.pb
is the same with output .pb
file of tf.compat.v1.graph_util.convert_variables_to_constants
?我不确定这个saved_model.pb
是否与 tf.compat.v1.graph_util.convert_variables_to_constants 的tf.compat.v1.graph_util.convert_variables_to_constants
.pb
文件相同?
If not, could someone recommed a better way to get frozen model (.pb) file?如果没有,有人可以推荐一种更好的方法来冻结 model (.pb) 文件吗?
Thanks.谢谢。
I have confirmed they are not the same.pb file.我已经确认它们不是同一个.pb 文件。 If you load and run SavedModel format, you'll get error: Data loss: Can't parse testmodel/saved_model.pb as binary proto
如果你加载并运行 SavedModel 格式,你会得到错误: Data loss: Can't parse testmodel/saved_model.pb as binary proto
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.