Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python keras.models.save_model中保存的_model.pb是否与tensorflow freeze_graph output.pb文件相同?_Python_Tensorflow_Keras_Save_Protocol Buffers - Fatal编程技术网

Python keras.models.save_model中保存的_model.pb是否与tensorflow freeze_graph output.pb文件相同?

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

在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.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解析为二进制协议