Python keras.models.save_model中保存的_model.pb是否与tensorflow freeze_graph output.pb文件相同?
在keras中训练模型后,我通常应用Python keras.models.save_model中保存的_model.pb是否与tensorflow freeze_graph output.pb文件相同?,python,tensorflow,keras,save,protocol-buffers,Python,Tensorflow,Keras,Save,Protocol Buffers,在keras中训练模型后,我通常应用tf.compat.v1.graph\u util.convert\u variables\u to\u constants或freeze\u 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.GFi
tf.compat.v1.graph\u util.convert\u variables\u to\u constants
或freeze\u 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_uutil.convert\u variables_to_u常量
标记为:Warning:此函数已被弃用
因此,我正在寻找生成.pb
文件的更新方法。我发现:keras.models.save_model()
保存模型和输出目录包含:
保存的资产\u model.pb变量
我不确定这个保存的\u model.pb
是否与tf.compat.v1.graph\u util.convert\u变量\u到\u常量的输出.pb
相同
如果没有,有人能推荐一种更好的方法来获取冻结的模型(.pb)文件吗
谢谢。我已经确认它们不是相同的.pb文件。如果加载并运行SavedModel格式,将出现错误:数据丢失:无法将testmodel/saved_model.pb解析为二进制协议