Skip to content Skip to sidebar Skip to footer

Invalidargumenterror (see Above For Traceback): Indices[1] = 10 Is Not In [0, 10)

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 w

Solution 1:

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:

  1. The dimensions of your data and your labels being different

  2. 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)}
    

Solution 2:

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.

Post a Comment for "Invalidargumenterror (see Above For Traceback): Indices[1] = 10 Is Not In [0, 10)"