python - 尝试恢复检查点时 Tensorflow 失败并显示 "Unable to get element from the feed as bytes."

标签 python tensorflow google-cloud-ml

我正在使用 Tensorflow r0.12。

我在本地使用 google-cloud-ml 来运行 2 个不同的训练作业。在第一份工作中,我为我的变量找到了很好的初始值。我将它们存储在 V2 检查点中。

当我尝试恢复我的变量以便在第二份工作中使用它们时:

import tensorflow as tf

sess = tf.Session()
new_saver = tf.train.import_meta_graph('../variables_pred/model.ckpt-10151.meta', clear_devices=True)
new_saver.restore(sess, tf.train.latest_checkpoint('../variables_pred/'))
all_vars = tf.trainable_variables()
for v in all_vars:
    print(v.name)

我收到以下错误信息:

tensorflow.python.framework.errors_impl.InternalError: Unable to get element from the feed as bytes.

检查点是在第一个作业中用这些行创建的:

saver = tf.train.Saver()
saver.export_meta_graph(filename=os.path.join(output_dir, 'export.meta'))
saver.save(sess, os.path.join(output_dir, 'export'), write_meta_graph=False)

根据 this answer ,它可能来自缺少元数据文件,但我正在加载元数据文件。

PS:我使用参数 clear_devices=True 因为在 google-cloud-ml 上启动生成的设备规范非常复杂,我不需要一定要得到相同的调度。

最佳答案

错误信息是由于不小心缺少了名为“checkpoint”的文件。

在适当的文件夹中重新引入此文件后,似乎检查点的加载工作正常。

很抱歉忽略了这个关键点。

关于python - 尝试恢复检查点时 Tensorflow 失败并显示 "Unable to get element from the feed as bytes.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41369062/

相关文章:

python - Celery、RabbitMQ、Redis : Celery message enters exchange, 但不排队?

python - 将 tensorflow 1.x.x 模型加载到 tensorflow 2.x.x

r - 如何使用 keras 和 pad_sequences 在 R 中填充文本序列?

google-cloud-platform - 使用自定义 docker 镜像启动 Google Cloud AI Platform Notebooks 的要求

python - 如何在tkinter中将 'text'按钮彼此进行比较?

python - 使用python获取ES索引中的所有文档

python - 有没有办法知道 Python 套接字中有多少数据可供接收?

python - tensorflow 2 : shape mismatch when serialize and decode it back

python - Google Cloud Machine Learning 如何处理大量 HDF5 文件?

tensorflow - 如何在 Google 云中设置 TensorFlow?