Reputation: 437
I am using tensorflow 1.0 CPU on ubuntu and python 3.5.
I adapted an example of tensorflow to work on my own dataset https://github.com/martin-gorner/tensorflow-mnist-tutorial
It works fine as long as the number of outputs is under 10. When the number of outputs is above 10,I get the error:
InvalidArgumentError (see above for traceback): indices[1] = 10 is not in [0, 10)
[[Node: Gather_4 = Gather[Tindices=DT_INT64,
Tparams=DT_FLOAT,
validate_indices=true,
_device="/job:localhost/replica:0/task:0/cpu:0"](grayscale_to_rgb, ArgMax_4)]]
Any help?
Upvotes: 3
Views: 6544
Reputation: 2909
I also came across the same error, and after fiddling with it for 2 days I came to realize there are 2 main reasons this error was getting thrown for my code and I mentioned them below to help anyone struggling with the same problem:
The dimensions of your data and your labels being different
In my case, the problem was that when building my vocabulary I have indexed the words from 1 and not from 0. But the embedded layer starts indexing from 0. So it kept giving me the mentioned error. I fixed the error by indexing my vocabulary from 0.
previous code:
dictionary = Counter(words)
sorted_split_words = sorted(dictionary, key=dictionary.get, reverse=True)
vocab_to_int = {c: i for i, c in enumerate(sorted_split_words, 1)}
to fix it I changed the last line to (removed 1):
vocab_to_int = {c: i for i, c in enumerate(sorted_split_words)}
Upvotes: 4
Reputation: 11
The index of the input word exceeds the length of the vocabulary, or the new words that are not included in the vocabulary.
Please try to enlarge vocabulary length.
Upvotes: 1