来自 keras.models.save_model 的 saved_model.pb 与 tensorflow freeze_graph 输出 .pb 文件相同吗?
Is saved_model.pb from keras.models.save_model the same with tensorflow freeze_graph output .pb file?
模型在keras训练后,我曾经应用tf.compat.v1.graph_util.convert_variables_to_constants
或freeze_graph.py
冻结模型并输出.pb文件。像这样:
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())
最近,我发现 tf.compat.v1.graph_util.convert_variables_to_constants
被标记为:Warning: THIS FUNCTION IS DEPRECATED
。
所以我正在寻找生成 .pb
文件的更新方法。我发现这个:keras.models.save_model()
to save model and output dir contains:
assets saved_model.pb variables
我不确定这个 saved_model.pb
是否与 tf.compat.v1.graph_util.convert_variables_to_constants
的输出 .pb
文件相同?
如果没有,有人可以推荐一种更好的方法来获取冻结模型 (.pb) 文件吗?
谢谢。
我已经确认它们不是同一个 .pb 文件。如果您加载 运行 SavedModel 格式,您将收到错误消息:Data loss: Can't parse testmodel/saved_model.pb as binary proto
模型在keras训练后,我曾经应用tf.compat.v1.graph_util.convert_variables_to_constants
或freeze_graph.py
冻结模型并输出.pb文件。像这样:
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())
最近,我发现 tf.compat.v1.graph_util.convert_variables_to_constants
被标记为:Warning: THIS FUNCTION IS DEPRECATED
。
所以我正在寻找生成 .pb
文件的更新方法。我发现这个:keras.models.save_model()
to save model and output dir contains:
assets saved_model.pb variables
我不确定这个 saved_model.pb
是否与 tf.compat.v1.graph_util.convert_variables_to_constants
的输出 .pb
文件相同?
如果没有,有人可以推荐一种更好的方法来获取冻结模型 (.pb) 文件吗?
谢谢。
我已经确认它们不是同一个 .pb 文件。如果您加载 运行 SavedModel 格式,您将收到错误消息:Data loss: Can't parse testmodel/saved_model.pb as binary proto