我正在尝试通过遵循Convolutional Neural Networks教程来学习tenforflow,但是当我试图弄清楚cifar10_input.py如何从cifar-10-batches-bin加载数据时,我遇到了Tensor.eval()执行很长时间的问题时间或永远没有结果.
代码是这样的:
import tensorflow as tf
from tensorflow.models.image.cifar10 import cifar10_input
filenames = ['/Users/me/Downloads/cifar-10-batches-bin/data_batch_1.bin']
filename_queue = tf.train.string_input_producer(filenames)
read_input = cifar10_input.read_cifar10(filename_queue)
reshaped_image = tf.cast(read_input.uint8image, tf.float32)
with tf.Session() as sess:
print reshaped_image.eval()
代码基本上来自cifar10_input.py,文件data_batch_1.bin是
从cifar-10-binary.tar.gz中提取.
通常,我可以使用其eval()方法观察张量.但在这种情况下,它持续运行的时间比以往任何时候都长(我等了将近一个小时,它仍在运行).我的代码中有什么问题吗?
解决方法:
1)作为基本的健全性检查:ls -al /Users/me/Downloads/cifar-10-batches-bin/data_batch_1.bin
2)不要忘记:
init = tf.initialize_all_variables()
sess.run(init)
3)tf.train.start_queue_runners()(创建会话后)
它可能是#3. string_input_producer
将队列运行器添加到需要启动的QUEUE_RUNNERS集合中.
原文地址:https://codeday.me/bug/20190516/1116363.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。