eliorc / node2vec

Implementation of the node2vec algorithm.
MIT License
1.2k stars 245 forks source link

error in node2vec fit #60

Open BSharmi opened 3 years ago

BSharmi commented 3 years ago

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)

in 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!
adamdingliang commented 3 years ago

I had the same error. Waiting for a response!

eliorc commented 3 years ago

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

adamdingliang commented 3 years ago

Downgrade gensim to 3.8.3 works.

BSharmi commented 3 years ago

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

eliorc commented 3 years ago

Solved in 4.2.0

p-dre commented 1 year ago

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

with node2vec 4.6

eliorc commented 1 year ago

Can you tell me which gensim version is installed?

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

with node2vec 4.6

MikeB2019x commented 1 year ago

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

eliorc commented 1 year ago

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?

MikeB2019x commented 1 year ago

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.

eliorc commented 1 year ago

I'll try to check it out in the weekend

eliorc commented 1 year ago

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

MikeB2019x commented 1 year ago

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: @.***>

eliorc commented 1 year ago

@MikeB2019x I'd love to accept it!