Tensorflow的Session.run()/ Tensor.eval()运行了很长时间

hsc*_*hsc 5 python tensorflow

我正在尝试通过跟随卷积神经网络教程学习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()
Run Code Online (Sandbox Code Playgroud)

代码基本上来自cifar10_input.pydata_batch_1.bin从中提取文件cifar-10-binary.tar.gz.

通常,我可以使用它的eval()方法观察张量.但在这种情况下,它持续运行的时间比以往任何时候都长(我等了将近一个小时,它仍在运行).我的代码中有什么问题吗?

dga*_*dga 6

1)作为基本的理智检查: ls -al /Users/me/Downloads/cifar-10-batches-bin/data_batch_1.bin

2)不要忘记:

init = tf.initialize_all_variables()
sess.run(init)
Run Code Online (Sandbox Code Playgroud)

3)tf.train.start_queue_runners() (创建会话后)

它可能是#3.在string_input_producer增加了一个队列运行的QUEUE_RUNNERS集合,它需要启动.