Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n2v - loadEmbedding IndexError, python 2.7 #34

Closed
dmpierre opened this issue Jun 21, 2018 · 5 comments
Closed

n2v - loadEmbedding IndexError, python 2.7 #34

dmpierre opened this issue Jun 21, 2018 · 5 comments

Comments

@dmpierre
Copy link

Hi Palash,

I think the loadEmbedding is encountering some issues, though I train the graph smoothly. I anyway can load the tempGraph.emb file but you may want to look at this traceback :)

Traceback (most recent call last): File "train.py", line 81, in <module> n2v_model = model.train_n2v_model(G, params) File "train.py", line 32, in train_n2v_model embedding.learn_embedding(g) File "/home/pdaixmor/.virtualenvs/word_embeddings/lib/python2.7/site-packages/gem-1.0.0-py2.7.egg/gem/embedding/node2vec.py", line 84, in learn_embedding self._X = graph_util.loadEmbedding('tempGraph.emb') File "/home/pdaixmor/.virtualenvs/word_embeddings/lib/python2.7/site-packages/gem-1.0.0-py2.7.egg/gem/utils/graph_util.py", line 170, in loadEmbedding X[int(emb[0]), :] = emb_fl IndexError: index 6256 is out of bounds for axis 0 with size 6224

@palash1992
Copy link
Owner

The nodes need to be contiguous. Do you think that can be the issue in your setting?

@dmpierre
Copy link
Author

Hey Palash, sorry for the late reply.

Yes that was the issue. Maybe a dict-like way for accessing the embeddings could be more appropriate for such a case - such as in gensim. What do you think? :)

@palash1992
Copy link
Owner

Yes I agree. I am currently working on an extension of the library. Perhaps once I am done with that I can make this change for both of them.

@Anjs04
Copy link

Anjs04 commented Aug 23, 2018

@dmpierre How did you load the embeddings without using loadEmbeddings()?

@dmpierre
Copy link
Author

Hi :)

Just comment out line 84 in node2vec.py:
self._X = graph_util.loadEmbedding('tempGraph.emb')

Then you can write your own kind of loadEmbedding function that best suits your needs.

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

No branches or pull requests

3 participants