简体   繁体   English

ValueError:传递的保存路径不是有效的检查点:/content/gdrive/My Drive\model\20191003053122/variables/variables

[英]ValueError: The passed save_path is not a valid checkpoint: /content/gdrive/My Drive\model\20191003053122/variables/variables

Ran the code跑代码

export_path= '/content/gdrive/My Drive'+ '\\model\\'+'20191003053122'

with tf.Session(graph=tf.Graph()) as sess:
    tf.saved_model.loader.load(sess, ["myTag"], export_path)         
    graph = tf.get_default_graph()

and incurred error并发生错误

ValueError: The passed save_path is not a valid checkpoint: /content/gdrive/My Drive\model\20191003053122/variables/variables

What I don't understand is that I have set the same path previously( export_path = '/content/gdrive/My Drive' +'\\model\\'+time.strftime("%Y%m%d%H%M%S",time.localtime()) ) but Google Colab still says the checkpoint not valid.我不明白的是我之前设置了相同的路径( export_path = '/content/gdrive/My Drive' +'\\model\\'+time.strftime("%Y%m%d%H%M%S",time.localtime()) )但 Google Colab 仍然说检查点无效。 What does it mean and went wrong?这是什么意思,出了什么问题? I also changed both paths multiple times(like replacing '/content/gdrive/My Drive' with os.getcwd()+ ) to make sure they match each other but didn't help.我还多次更改了两条路径(例如用os.getcwd()+替换'/content/gdrive/My Drive' )以确保它们相互匹配但没有帮助。

I am wondering if it's because the code我想知道是不是因为代码

with tf.Session(graph=tf.Graph()) as sess:
    tf.saved_model.loader.load(sess, ["myTag"], export_path)         
    graph = tf.get_default_graph()

is deprecated- if that's the case, what equivalent should I use instead?已弃用-如果是这种情况,我应该改用什么等价物? Maybe Keras ?也许Keras Any contribution is appreciated.任何贡献表示赞赏。 Thanks谢谢

It looks like there is an access issue between Google Colab and Google drive Google Colab 和 Google Drive 之间似乎存在访问问题

Can you take a step back and verify whether your Google drive is mounted properly and you are able to write and read files via Goole Colab.?您能否退一步验证您的 Google 驱动器是否已正确安装以及您是否能够通过 Goole Colab 写入和读取文件。?

Here are the steps to be followed:以下是要遵循的步骤:

  1. Import and mount Google Drive导入和挂载 Google Drive

     from google.colab import drive drive.mount('/content/gdrive')
  2. Verify you are able to list the files in your drive or the location you want to write into验证您是否能够列出驱动器中的文件或要写入的位置

    !ls "/content/gdrive/My Drive"
  3. Write the file in Google Drive,将文件写入 Google Drive,

    I have used "w" so that it creates the file if it doesn't exist我使用了"w" ,以便在文件不存在时创建文件

    Other file modes in Python open() function Python open() function 中的其他文件模式

    with open("/content/gdrive/My Drive/myFile.txt", "w") as file: file.write("Your text goes here")
  4. Read the file again to check if the writing file went well!再次读取文件以检查写入文件是否顺利!

     .cat "/content/gdrive/My Drive/myFile.txt"

Image of my Google colab working code snippet我的 Google colab 工作代码片段的图像

You can even check the official Goolge Colab notebook with steps here 您甚至可以在此处查看官方 Goolge Colab 笔记本的步骤

Hope this helps:)希望这可以帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM