models icon indicating copy to clipboard operation
models copied to clipboard

Invalid argument: indices[0] = [0,148] is out of bounds: need 0 <= index < [32,6]

Open cosmok opened this issue 10 years ago • 8 comments

I am trying to create a new inception model using: bazel-bin/inception/flowers_train --train_dir="${TRAIN_DIR}" --data_dir="${FLOWERS_DATA_DIR}" --fine_tune=True --initial_learning_rate=0.001 --input_queue_memory_factor=1

and getting this error: W tensorflow/core/framework/op_kernel.cc:896] Invalid argument: indices[0] = [0,148] is out of bounds: need 0 <= index < [32,6]

I have run build_image_data to create FLOWERS_DATA_DIR

Can I create a new inception model this way?

cosmok avatar Mar 13 '16 21:03 cosmok

Would you be able to provide more details about what you have modified and possibly the full log of running the model?

shlens avatar Mar 14 '16 17:03 shlens

How can I create a inception model on a custom dataset (not flowers. I am piggy backing off the flowers train scripts)?

Below is the complete error `$ bazel-bin/inception/flowers_train --train_dir="${TRAIN_DIR}" --data_dir="${FLOWERS_DATA_DIR}" --fine_tune=True --initial_learning_r ate=0.001 --input_queue_memory_factor=1

W tensorflow/core/framework/op_kernel.cc:896] Invalid argument: indices[0] = [0,44] is out of bounds: need 0 <= index < [32,6] Traceback (most recent call last): File "/Users/k7/workspace/tensor_models/inception/bazel-bin/inception/flowers_train.runfiles/inception/flowers_train.py", line 41, in tf.app.run() File "/Library/Python/2.7/site-packages/tensorflow/python/platform/default/_app.py", line 30, in run sys.exit(main(sys.argv)) File "/Users/k7/workspace/tensor_models/inception/bazel-bin/inception/flowers_train.runfiles/inception/flowers_train.py", line 37, in main inception_train.train(dataset) File "/Users/k7/workspace/tensor_models/inception/bazel-bin/inception/flowers_train.runfiles/inception/inception_train.py", line 332, in train _, loss_value = sess.run([train_op, loss]) File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 313, in run return self._run(None, fetches, feed_dict) File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 509, in _run feed_dict_string) File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 562, in _do_run target_list) File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 584, in _do_call e.code) tensorflow.python.framework.errors.InvalidArgumentError: indices[0] = [0,44] is out of bounds: need 0 <= index < [32,6] [[Node: tower_0/SparseToDense = SparseToDense[T=DT_FLOAT, Tindices=DT_INT32, validate_indices=true, _device="/job:localhost/replica:0/task:0/cpu:0"](tower_0/concat, tower_0/SparseToDense/output_shape, tower_0/SparseToDense/sparse_values, tower_0/SparseToDense/default_value)]] Caused by op u'tower_0/SparseToDense', defined at: File "/Users/k7/workspace/tensor_models/inception/bazel-bin/inception/flowers_train.runfiles/inception/flowers_train.py", line 41, in tf.app.run() File "/Library/Python/2.7/site-packages/tensorflow/python/platform/default/_app.py", line 30, in run sys.exit(main(sys.argv)) File "/Users/k7/workspace/tensor_models/inception/bazel-bin/inception/flowers_train.runfiles/inception/flowers_train.py", line 37, in main inception_train.train(dataset) File "/Users/k7/workspace/tensor_models/inception/bazel-bin/inception/flowers_train.runfiles/inception/inception_train.py", line 235, in train loss = _tower_loss(images, labels, num_classes, scope) File "/Users/k7/workspace/tensor_models/inception/bazel-bin/inception/flowers_train.runfiles/inception/inception_train.py", line 115, in _tower_loss inception.loss(logits, labels, batch_size=split_batch_size) File "/Users/k7/workspace/tensor_models/inception/bazel-bin/inception/flowers_train.runfiles/inception/inception_model.py", line 125, in loss 1.0, 0.0) File "/Library/Python/2.7/site-packages/tensorflow/python/ops/sparse_ops.py", line 362, in sparse_to_dense name=name) File "/Library/Python/2.7/site-packages/tensorflow/python/ops/gen_sparse_ops.py", line 362, in _sparse_to_dense validate_indices=validate_indices, name=name) File "/Library/Python/2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 655, in apply_op op_def=op_def) File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 2102, 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 1129, in init self._traceback = _extract_stack()`

cosmok avatar Mar 15 '16 20:03 cosmok

Piggy-backing on the flowers data set is precisely our intention for releasing the example of the flowers data set, so I am glad it provides a good start.

Did you already generate the data and place it in $FLOWERS_DATA_DIR?

Also, if you did generate the new data set already, did you update num_classes() and num_examples_per_epoch() in flowers_data.py to correspond with your data?

https://github.com/tensorflow/models/blob/master/inception/inception/flowers_data.py#L34

shlens avatar Mar 15 '16 21:03 shlens

Ah, didn't realize that I had explicitly set those (as that info could have been determined at runtime).

I have got the training script to run now. Thanks a lot for your help!

cosmok avatar Mar 16 '16 11:03 cosmok

Hi, could this please become part of the writeup here: https://github.com/tensorflow/models/blob/master/inception/README.md

It has tripped me up and I'm sure others will also not realize that this needs to be done.

Thanks.

achaiah avatar Jun 13 '16 16:06 achaiah

I am trying to build a model using flowers_train.py and got the same error. Here I changed the "examples" and "classes" for both flowers_data.py and build_image_data.py corresponding to my custom data. Still I am stuck with this error. Can anyone help me with this issue?

pavanyvs avatar Oct 05 '17 11:10 pavanyvs

i have encounter this problem ,too. that indicates that your indicies do be out of bound . print it ,and check carefully. best wishes.

s-mason avatar Jun 19 '18 11:06 s-mason

I meet the similar problem. I found my labels begin from 1 but not 0, so I changed the sequence of labels. Hope my answer can help you !

zane-wong-developer avatar Jul 19 '19 05:07 zane-wong-developer