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

标签 python tensorflow google-colaboratory

我运行了代码

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中运行。我不确定是不是因为这个。任何帮助表示赞赏。谢谢你。

最佳答案

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

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

关于python - OSError : SavedModel file does not exist at:/content\model\2016/{saved_model. pbtxt|saved_model.pb},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58194951/

相关文章:

c++ - C++ 中的仅限 gRPC 的 Tensorflow 服务客户端

python - 为什么这个神经网络的准确率为零,损失极低?

python - 如何使用 python 在 google colab 中保存 json 转储?

python - 如何从 selenium 和 python 中的文件对话框中选择文件

python - 如何分割成 block (子矩阵),或处理一个巨大的矩阵,在 numpy 上给出内存错误?

python - 如何在 LSTM 中实现 Tensorflow 批量归一化

python - 如何在另一个笔记本中运行 Jupyter 笔记本

terminal - 如何与 google colab 中当前正在运行的命令单元进行交互?

python - 使用 cython 加速 itertools 组合

python - 使用 Django Rest Framework 序列化器更新现有模型