node2vec icon indicating copy to clipboard operation
node2vec copied to clipboard

error in node2vec fit

Open BSharmi opened this issue 3 years ago • 14 comments

Hello,

I ran the commands using the default data in the package and get the following error in the embed node step in the node2vec.fit step

import networkx as nx from node2vec import Node2Vec graph = nx.fast_gnp_random_graph(n=100, p=0.5) node2vec = Node2Vec(graph, dimensions=64, walk_length=30, num_walks=200, workers=4) model = node2vec.fit(window=10, min_count=1, batch_words=4)

error

--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-1-66dd459dbca1> in <module> 9 10 # Embed nodes ---> 11 model = node2vec.fit(window=10, min_count=1, batch_words=4) ~/anaconda3/envs/default/lib/python3.8/site-packages/node2vec/node2vec.py in fit(self, **skip_gram_params) 181 skip_gram_params['sg'] = 1 182 --> 183 return gensim.models.Word2Vec(self.walks, **skip_gram_params) TypeError: __init__() got an unexpected keyword argument 'size'

I have installed the required packages. Is there any step I missed?

Would appreciate a response!

Thank you!

BSharmi avatar Mar 31 '21 04:03 BSharmi

I had the same error. Waiting for a response!

adamdingliang avatar Mar 31 '21 06:03 adamdingliang

Yes, gensim has changed their interface, you can wither downgrade gensim to version less than 4 or wait for the weekedn and I'll fix it as I noted in #59

eliorc avatar Mar 31 '21 08:03 eliorc

Downgrade gensim to 3.8.3 works.

adamdingliang avatar Apr 01 '21 05:04 adamdingliang

I would wait for the fix. Thanks very much for looking into it!

BSharmi avatar Apr 01 '21 16:04 BSharmi

Solved in 4.2.0

eliorc avatar Apr 02 '21 06:04 eliorc

TypeError: Word2Vec.init() got an unexpected keyword argument 'size'

with node2vec 4.6

p-dre avatar Jan 27 '23 10:01 p-dre

Can you tell me which gensim version is installed?

TypeError: Word2Vec.init() got an unexpected keyword argument 'size'

with node2vec 4.6

eliorc avatar Jan 27 '23 14:01 eliorc

Fix for that is as follows. Replace the variable names in the Word2Vec call:

  • 'iter' -> 'epochs'
  • 'size' -> 'vector_size'

MikeB2019x avatar Feb 06 '23 15:02 MikeB2019x

Fix for that is as follows. Replace the variable names in the Word2Vec call:

  • 'iter' -> 'epochs'
  • 'size' -> 'vector_size'

Before validating a fix, I want to reproduce, can you tell me with which version of gensim and node2vec are you getting errors?

eliorc avatar Feb 06 '23 15:02 eliorc

Sorry about that :-D I was using: gensim 4.2.0 but encountered the problem while working with the struc2vec repo here. Basically a fork of your latest and then tried to get everything working in Python3 with the pr from @steenfatt. This is the link to the gensim 4.2.0 word2vec.py.

MikeB2019x avatar Feb 06 '23 16:02 MikeB2019x

I'll try to check it out in the weekend

eliorc avatar Feb 09 '23 08:02 eliorc

I can't find time to do this, I'd appreciate if anyone wants to contribute through a PR @MikeB2019x @p-dre

eliorc avatar Apr 12 '23 06:04 eliorc

I can do that.

http://mindbridge.ai/

Michael Bourassa

Data Scientist | MindBridge

+1 613-894-9189 <+1-613-894-9189>

Bourassa

mindbridge.ai

[image: twitter] https://twitter.com/mindbridge_ai

[image: linkedin] https://www.linkedin.com/company/mindbridge-ai/

[image: banner] https://www.mindbridge.ai/news/mindbridge-named-to-forbes-ai-50-list-of-most-promising-ai-companies

On Wed, Apr 12, 2023 at 2:53 AM Elior Cohen @.***> wrote:

I can't find time to do this, I'd appreciate if anyone wants to contribute through a PR @MikeB2019x https://github.com/MikeB2019x @p-dre https://github.com/p-dre

— Reply to this email directly, view it on GitHub https://github.com/eliorc/node2vec/issues/60#issuecomment-1504757987, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALV3V75KJ5TLOS56ARVLG5LXAZGQPANCNFSM42DV7BSQ . You are receiving this because you were mentioned.Message ID: @.***>

MikeB2019x avatar Apr 12 '23 12:04 MikeB2019x

@MikeB2019x I'd love to accept it!

eliorc avatar Apr 13 '23 05:04 eliorc