phanein / deepwalk

DeepWalk - Deep Learning for Graphs
http://www.perozzi.net/projects/deepwalk/
Other
2.68k stars 826 forks source link

TypeError: unsupported operand type(s) for +: 'int' and 'str' #3

Closed Minimong closed 9 years ago

Minimong commented 9 years ago

Hi@phanein, There is a problem when I run sudo deepwalk --input example_graphs/karate.adjlist --output karate.embeddings

Here are the error messages:

Number of nodes: 34 Number of walks: 340 Data size (walks*length): 13600 Walking... Training... Traceback (most recent call last): File "/usr/local/bin/deepwalk", line 9, in load_entry_point('deepwalk==1.0.1', 'console_scripts', 'deepwalk')() File "/usr/local/lib/python2.7/dist-packages/deepwalk-1.0.1-py2.7.egg/deepwalk/main.py", line 155, in main process(args) File "/usr/local/lib/python2.7/dist-packages/deepwalk-1.0.1-py2.7.egg/deepwalk/main.py", line 69, in process model = Word2Vec(walks, size=args.representation_size, window=args.window_size, min_count=0, workers=args.workers) File "/usr/local/lib/python2.7/dist-packages/gensim/models/word2vec.py", line 312, in init self.build_vocab(sentences) File "/usr/local/lib/python2.7/dist-packages/gensim/models/word2vec.py", line 414, in build_vocab self.reset_weights() File "/usr/local/lib/python2.7/dist-packages/gensim/models/word2vec.py", line 521, in reset_weights random.seed(uint32(self.hashfxn(self.index2word[i] + str(self.seed)))) TypeError: unsupported operand type(s) for +: 'int' and 'str'

phanein commented 9 years ago

Thanks for reporting - this is an incompatibility with the latest version of gensim.

I've updated the requirements file, which will now install the latest version that works (0.10.2). To fix:

  1. pip uninstall gensim
  2. pip uninstall deepwalk
  3. pip install gensim==0.10.2
  4. pip install deepwalk==v1.0.2
Minimong commented 9 years ago

Thanks phanein.

It works in Python2.

tigerneil commented 9 years ago

I just changed the code in word2vec.py, from random.seed(uint32(self.hashfxn(self.index2word[i] + str(self.seed)))) to random.seed(uint32(self.hashfxn(str(self.index2word[i]) + str(self.seed))))

loretoparisi commented 8 years ago

@tigerneil this solution worked! Infact downgrading to prior version causes other libraries to fail for older versions of gensim! By the way I have reported this https://github.com/RaRe-Technologies/gensim/issues/846