Skip to content

Training Inception from scratch on Custom Data: InvalidArgumentError: indices[0] = [0,1271] is out of bounds: need 0 <= index < [32,4] #566

@samspills

Description

@samspills

I'm trying to do a test run of the training process on a subset of my data before I attempt to train on the full set. I have 4 labels, and 981 images total. I generated the tf.Records (4 shards) with build_image_data.py with only minor problems (some images had a .jpg extension but were secretly .png's, but I wrote a check to convert those).

I ran bazel build inception/imagenet_train, and then I updated imagenet_data.py to set num_classes and num_examples to be 4, and 981 respectively.

When I try to run bazel-bin/inception/imagenet_train --num_gpus=1 --batch_size=32 --train_dir=/tmp/imagenet_train --data_dir=/tmp/imagenet_data, I'm getting the error I posted in the title (and a more complete traceback follows). Googling seems to suggest that this error arises when num_classes or num_examples is not set, but I've definitely done that. Did I set them incorrectly?

W tensorflow/core/framework/op_kernel.cc:936] Invalid argument: indices[0] = [0,755] is out of bounds: need 0 <= index < [32,5]
E tensorflow/core/client/tensor_c_api.cc:485] indices[0] = [0,755] is out of bounds: need 0 <= index < [32,5]
         [[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)]]
Traceback (most recent call last):
  File "/Users/work/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 730, in _do_call
    return fn(*args)
  File "/Users/work/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 712, in _run_fn
    status, run_metadata)
  File "/Users/work/anaconda3/lib/python3.5/contextlib.py", line 66, in __exit__
    next(self.gen)
  File "/Users/work/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/errors.py", line 450, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors.InvalidArgumentError: indices[0] = [0,755] is out of bounds: need 0 <= index < [32,5]
         [[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)]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions