Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.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 无法将.ckpt.meta文件转换为.pb文件_Python_Tensorflow_Jupyter Notebook - Fatal编程技术网

Python 无法将.ckpt.meta文件转换为.pb文件

Python 无法将.ckpt.meta文件转换为.pb文件,python,tensorflow,jupyter-notebook,Python,Tensorflow,Jupyter Notebook,对不起,上下文含糊不清 我收到一个来自某个人的.ckpt.meta文件,用于他们培训的模型,我正在尝试将.ckpt.meta文件转换为.pb文件。 搜索论坛,我能够得到一个特定的代码块用于此目的 import tensorflow.compat.v1 as tf meta_path = '/content/drive/My Drive/snapshot_12.ckpt.meta' # Your .meta file output_node_names = ['output:0'] # Ou

对不起,上下文含糊不清

我收到一个来自某个人的.ckpt.meta文件,用于他们培训的模型,我正在尝试将.ckpt.meta文件转换为.pb文件。 搜索论坛,我能够得到一个特定的代码块用于此目的

import tensorflow.compat.v1 as tf
meta_path = '/content/drive/My Drive/snapshot_12.ckpt.meta' # Your .meta file
output_node_names = ['output:0']    # Output nodes

with tf.Session() as sess:
    # Restore the graph
    saver = tf.train.import_meta_graph(meta_path)
    sess = tf.Session(config=tf.ConfigProto(
      allow_soft_placement=True, log_device_placement=True))
    # Load weights
    saver.restore(sess,'/content/drive/My Drive/snapshot_12.ckpt.meta')

    output_node_names = [n.name for n in tf.get_default_graph().as_graph_def().node]

    # Freeze the graph
    frozen_graph_def = tf.graph_util.convert_variables_to_constants(
        sess,
        sess.graph_def,
        output_node_names)

    # Save the frozen graph
    with open('output_graph.pb', 'wb') as f:
      f.write(frozen_graph_def.SerializeToString())
在google colab上运行时出错

错误

这个错误有什么解决办法吗?谢谢你的帮助

DataLossError: Unable to open table file /content/drive/My Drive/snapshot_12.ckpt.meta: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
     [[{{node save/RestoreV2}}]]