【问题标题】:OSError: SavedModel file does not exist at: /content\model\2016/{saved_model.pbtxt|saved_model.pb}OSError:SavedModel 文件不存在于:/content\model\2016/{saved_model.pbtxt|saved_model.pb}
【发布时间】:2020-01-31 08:17:38
【问题描述】:

我运行了代码

export_path=os.getcwd()+'\\model\\'+'2016'

with tf.Session(graph=tf.Graph()) as sess:
    tf.saved_model.loader.load(sess, ["myTag"], export_path)          
    graph = tf.get_default_graph()
#    print(graph.get_operations())
    input = graph.get_tensor_by_name('input:0')
    output = graph.get_tensor_by_name('output:0')    
#     print(sess.run(output,
#                feed_dict={input: [test_data[1]]}))
    tf.train.write_graph(freeze_session(sess), export_path, "my_model.pb", as_text=False)

并引发以下错误

OSError                                   Traceback (most recent call last)
<ipython-input-44-b154e11ca364> in <module>()
      3 
      4 with tf.Session(graph=tf.Graph()) as sess:
----> 5     tf.saved_model.loader.load(sess, ["myTag"], export_path)          
      6     graph = tf.get_default_graph()
      7 #    print(graph.get_operations())

3 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/saved_model/loader_impl.py in parse_saved_model(export_dir)
     81                   (export_dir,
     82                    constants.SAVED_MODEL_FILENAME_PBTXT,
---> 83                    constants.SAVED_MODEL_FILENAME_PB))
     84 
     85 

OSError: SavedModel file does not exist at: /content\model\2016/{saved_model.pbtxt|saved_model.pb}

以前在Windows系统下运行,现在在IOS系统上运行。我不确定是不是因为这个。任何帮助表示赞赏。谢谢。

【问题讨论】:

    标签: python tensorflow google-colaboratory


    【解决方案1】:

    您应该避免使用固定字符作为目录分隔符(例如您的示例中的\),因为该字符在操作系统之间有所不同(请参阅os.sep)。 您可能希望使用os.path.joinPath 来构建路径,从而确保为正在执行的操作系统创建合适的路径,例如:

    export_path = os.path.join(os.getcwd(), 'model', '2016')
    

    【讨论】:

    • 嘿,谢谢你的回答,但似乎什么都没有改变:/
    猜你喜欢
    • 2020-08-25
    • 2020-10-03
    • 2020-05-21
    • 1970-01-01
    • 1970-01-01
    • 2022-08-02
    • 1970-01-01
    • 1970-01-01
    • 2020-04-17
    相关资源
    最近更新 更多