Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why these errors?How to solve? #38

Closed
ghost opened this issue Dec 16, 2016 · 2 comments
Closed

Why these errors?How to solve? #38

ghost opened this issue Dec 16, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Dec 16, 2016

Code:

  1. import tensorflow as tf
  2. import tensorlayer as tl
  3. import numpy as np
  4. from PIL import Image
  5. import os
  6. def _int64_feature(value):
  7. return tf.train.Feature(int64_list=tf.train.Int64List(value=[value]))
    
  8. def _bytes_feature(value):
  9. return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
    
  10. path_save = r'W:/PlantClassification/'
  11. path_train = r"W:/PlantClassification/train/"
  12. classes = [str(i) for i in list(range(7))]
  13. writer = tf.python_io.TFRecordWriter(path_save + 'train.tfrecords')
  14. for index, name in enumerate(classes):
  15. class_path = path_train + name + '/'
    
  16. for img_name in os.listdir(class_path):
    
  17.     img_path = class_path + img_name
    
  18.     img = Image.open(img_path)
    
  19.     img = img.resize((227, 227))
    
  20.     img_raw = img.tobytes()
    
  21.     example = tf.train.Example(features=tf.train.Features(feature={
    
  22.         'label': _int64_feature(index),
    
  23.         'img_raw': _bytes_feature(img_raw)}))
    
  24.     writer.write(example.SerializeToString())
    
  25. writer.close()
  26. def read_and_decode(filename):
  27. filename_queue = tf.train.string_input_producer([filename])
    
  28. reader = tf.TFRecordReader()
    
  29. _, serialized_example = reader.read(filename_queue)
    
  30. features = tf.parse_single_example(serialized_example,
    
  31.                                    features={
    
  32.                                        'label': tf.FixedLenFeature([], tf.int64),
    
  33.                                        'img_raw': tf.FixedLenFeature([], tf.string),
    
  34.                                    })
    
  35. # You can do more image distortion here for training data
    
  36. img = tf.decode_raw(features['img_raw'], tf.float32)
    
  37. img = tf.reshape(img, [227, 227, 3])
    
  38. label = tf.cast(features['label'], tf.int32)
    
  39. return img, label
    
  40. img, label = read_and_decode(r"W:\PlantClassification\train.tfrecords")
  41. img_batch, label_batch = tf.train.shuffle_batch([img, label],
  42.                                             batch_size=4,
    
  43.                                             capacity=150000,
    
  44.                                             min_after_dequeue=2000,
    
  45.                                             num_threads=4)
    
  46. init = tf.global_variables_initializer()
  47. with tf.Session() as sess:
  48. sess.run(init)
    
  49. coord = tf.train.Coordinator()
    
  50. threads = tf.train.start_queue_runners(sess=sess, coord=coord)
    
  51. for i in range(3):
    
  52.     print("Step %d" % i)
    
  53.     val, l = sess.run([img_batch, label_batch])
    
  54.     print(val.shape, l)
    
  55.     tl.visualize.images2d(val, second=1, saveable=False, name='batch' + str(i), dtype=np.uint8, fig_idx=2020121)
    
  56. coord.request_stop()
    
  57. coord.join(threads)
    
  58. sess.close()
    

Error:
S:\Python35\python.exe W:/PlantClassification/visualize_data.py
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cublas64_80.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cudnn64_5.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cufft64_80.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library nvcuda.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library curand64_80.dll locally
img_batch : (4, 227, 227, 3)
label_batch : (4,)
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:885] Found device 0 with properties:
name: GeForce GTX 960
major: 5 minor: 2 memoryClockRate (GHz) 1.1775
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 1.64GiB
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:906] DMA: 0
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:916] 0: Y
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 960, pci bus id: 0000:01:00.0)
Step 0
W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\framework\op_kernel.cc:975] Invalid argument: Input to DecodeRaw has length 154587 that is not a multiple of 4, the size of float
[[Node: DecodeRaw = DecodeRawlittle_endian=true, out_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]]
W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\framework\op_kernel.cc:975] Invalid argument: Input to DecodeRaw has length 154587 that is not a multiple of 4, the size of float
[[Node: DecodeRaw = DecodeRawlittle_endian=true, out_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]]
W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\framework\op_kernel.cc:975] Invalid argument: Input to DecodeRaw has length 154587 that is not a multiple of 4, the size of float
[[Node: DecodeRaw = DecodeRawlittle_endian=true, out_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]]
W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\framework\op_kernel.cc:975] Invalid argument: Input to DecodeRaw has length 154587 that is not a multiple of 4, the size of float
[[Node: DecodeRaw = DecodeRawlittle_endian=true, out_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]]
Traceback (most recent call last):
File "S:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1021, in _do_call
return fn(*args)
File "S:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1003, in _run_fn
status, run_metadata)
File "S:\Python35\lib\contextlib.py", line 66, in exit
next(self.gen)
File "S:\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 469, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 4, current size 0)
[[Node: shuffle_batch = QueueDequeueMany[_class=["loc:@shuffle_batch/random_shuffle_queue"], component_types=[DT_FLOAT, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "W:/PlantClassification/visualize_data.py", line 39, in
val, l = sess.run([img_batch, label_batch])
File "S:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 766, in run
run_metadata_ptr)
File "S:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 964, in _run
feed_dict_string, options, run_metadata)
File "S:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1014, in _do_run
target_list, options, run_metadata)
File "S:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1034, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 4, current size 0)
[[Node: shuffle_batch = QueueDequeueMany[_class=["loc:@shuffle_batch/random_shuffle_queue"], component_types=[DT_FLOAT, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

Caused by op 'shuffle_batch', defined at:
File "W:/PlantClassification/visualize_data.py", line 27, in
num_threads=4)
File "S:\Python35\lib\site-packages\tensorflow\python\training\input.py", line 917, in shuffle_batch
dequeued = queue.dequeue_many(batch_size, name=name)
File "S:\Python35\lib\site-packages\tensorflow\python\ops\data_flow_ops.py", line 458, in dequeue_many
self._queue_ref, n=n, component_types=self._dtypes, name=name)
File "S:\Python35\lib\site-packages\tensorflow\python\ops\gen_data_flow_ops.py", line 1099, in _queue_dequeue_many
timeout_ms=timeout_ms, name=name)
File "S:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 759, in apply_op
op_def=op_def)
File "S:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2240, in create_op
original_op=self._default_original_op, op_def=op_def)
File "S:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1128, in init
self._traceback = _extract_stack()

OutOfRangeError (see above for traceback): RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 4, current size 0)
[[Node: shuffle_batch = QueueDequeueMany[_class=["loc:@shuffle_batch/random_shuffle_queue"], component_types=[DT_FLOAT, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

Process finished with exit code 1

@zsdonghao
Copy link
Member

What data are you going to read? How did you create these data?
I think this is the key part:

W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\framework\op_kernel.cc:975] Invalid argument: Input to DecodeRaw has length 154587 that is not a multiple of 4, the size of float
[[Node: DecodeRaw = DecodeRawlittle_endian=true, out_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]]

@zsdonghao
Copy link
Member

Automatically closing due to lack of recent activity. Please reopen when additional information becomes available. Thanks!

zsdonghao added a commit that referenced this issue May 4, 2019
Update docs and travis.yml for 2.0 release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant