backstopmedia / tensorflowbook

459 stars 297 forks source link

Running logistic regression throws error #9

Closed vajrasky closed 8 years ago

vajrasky commented 8 years ago

The example code that can be found in https://raw.githubusercontent.com/backstopmedia/tensorflowbook/master/chapters/04_machine_learning_basics/logistic_regression.py throws error.

Platform: Mac Tensorflow version: 0.9


Traceback (most recent call last):
  File "logistic_regression.py", line 90, in <module>
    sess.run([train_op])
  File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 372, in run
    run_metadata_ptr)
  File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 636, in _run
    feed_dict_string, options, run_metadata)
  File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 708, in _do_run
    target_list, options, run_metadata)
  File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 728, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors.OutOfRangeError: RandomShuffleQueue '_0_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 100, current size 0)
     [[Node: shuffle_batch = QueueDequeueMany[_class=["loc:@shuffle_batch/random_shuffle_queue"], component_types=[DT_FLOAT, DT_FLOAT, DT_INT32, DT_STRING, DT_STRING, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_STRING, DT_FLOAT, DT_STRING, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
Caused by op u'shuffle_batch', defined at:
  File "logistic_regression.py", line 79, in <module>
    X, Y = inputs()
  File "logistic_regression.py", line 46, in inputs
    read_csv(100, "train.csv", [[0.0], [0.0], [0], [""], [""], [0.0], [0.0], [0.0], [""], [0.0], [""], [""]])
  File "logistic_regression.py", line 41, in read_csv
    min_after_dequeue=batch_size)
  File "/Library/Python/2.7/site-packages/tensorflow/python/training/input.py", line 779, in shuffle_batch
    dequeued = queue.dequeue_many(batch_size, name=name)
  File "/Library/Python/2.7/site-packages/tensorflow/python/ops/data_flow_ops.py", line 434, in dequeue_many
    self._queue_ref, n=n, component_types=self._dtypes, name=name)
  File "/Library/Python/2.7/site-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 465, in _queue_dequeue_many
    timeout_ms=timeout_ms, name=name)
  File "/Library/Python/2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 704, in apply_op
    op_def=op_def)
  File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 2260, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 1230, in __init__
    self._traceback = _extract_stack()
samjabrahams commented 8 years ago

Hi @vajrasky - sorry for the delayed response. This has just been fixed with commit cbe987a93f5ef95ab88405fd5; you can see more related conversation in #6.

Thanks so much for opening this up!