hsc
hsc

Reputation: 1298

Session.run() /Tensor.eval() of Tensorflow run for a crazy long time

I am trying to learn tenforflow by following the Convolutional Neural Networks tutorial, but when I was trying to figure out how cifar10_input.py loads data from cifar-10-batches-bin, I encountered a problem that Tensor.eval() executes for a very long time or runs forever without a result. The code is like this:

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()

The code is basically from cifar10_input.py and the file data_batch_1.bin is extracted from cifar-10-binary.tar.gz

Normally, I can observe a tensor using its eval() method. But in this case it runs continually for a longer time than ever(I waited for nearly an hour and it was still running). Is there something wrong in my code?

Upvotes: 7

Views: 1731

Answers (1)

dga
dga

Reputation: 21917

1) As a basic sanity check: ls -al /Users/me/Downloads/cifar-10-batches-bin/data_batch_1.bin

2) Don't forget to:

init = tf.initialize_all_variables()
sess.run(init)

3) tf.train.start_queue_runners() (after creating your session)

It's probably #3. The string_input_producer adds a queue runner to the QUEUE_RUNNERS collection, which needs to be started.

Upvotes: 8

Related Questions