Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[4,0] = 10000 is not in [0, 10000) #1

Closed
shenGrant opened this issue Dec 14, 2018 · 4 comments

Comments

@shenGrant
Copy link

Hi Gilbert,
Have u encountered this problem? i have not changed ur codes, and run it on local.
Thanks

@adam7902
Copy link

the same to you

InvalidArgumentError (see above for traceback): indices[7,0] = 10000 is not in [0, 10000)

@TannerGilbert
Copy link
Owner

TannerGilbert commented Jan 4, 2019

Found the error. I used an wrong input_dim. It should be maximum integer index + 1 as explained in the Keras documentation and I just used the maximum integer index.

Sorry for not answering earlier but I completely overlooked the issues. Furthermore it looks like this error only occurres when using a CPU and therefore it worked just fine for me. Now(after the bug fix) I tried it with both CPU and GPU and it works fine for me.

Kind regards,
Gilbert Tanner

TannerGilbert added a commit that referenced this issue Jan 4, 2019
@TannerGilbert TannerGilbert pinned this issue Jan 4, 2019
@bhansa
Copy link

bhansa commented Apr 8, 2019

Hi @TannerGilbert,
First of all, thanks for the notebook, it's very helpful. I got the same error while trying to run the code.
Below are some details about my dataset and dimensions which I was passing. I tried to use the dot product example(method 1).

train.head()
BookID UserID USERRATINGS
114530 644108 4
114530 614998 4
114530 618764 4
114530 608366 4
114530 655265 4
n_users = len(dataset.UserID.unique())
print(n_users) #12915

n_books = len(dataset.BookID.unique())
print(n_books) #4469

InvalidArgumentError: indices[0,0] = 114530 is not in [0, 4470)
	 [[{{node Book-Embedding_4/embedding_lookup}}]]

Let me know if you have any idea about this issue.

Thanks,
Bharat

@TannerGilbert
Copy link
Owner

Hello @bhansa,

This error occurres when using the false input_dim for the embedding layers. The input_dim attribute for the embedding layer in Keras is defined as follows:

  • input_dim: int > 0. Size of the vocabulary, i.e. maximum integer index + 1.

Maybe you need to add 1 as indicated above. Check out this stackoverflow post for more information.

Hope this helped.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants