我正在使用 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/