Git Product home page Git Product logo

Comments (14)

HKUSTmji avatar HKUSTmji commented on August 15, 2024 5

I also have the similiar problem on Linux 14.04 LTS, would you mind helping me for this issue? Thanks in advance.

BTW, I got Cython version 0.24 after comment cython -V.

mji@EEE0625:~/modelzoo/deepwalk/deepwalk-1.0.2$ deepwalk --input example_graphs/karate.adjlist --output karate.embeddings
Number of nodes: 34
Number of walks: 340
Data size (walks*length): 13600
Walking...
Training...
/home/mji/anaconda2/lib/python2.7/site-packages/gensim/models/word2vec.py:406: UserWarning: Cython compilation failed, training will be slow. Do you have Cython installed? pip install cython
warnings.warn("Cython compilation failed, training will be slow. Do you have Cython installed? pip install cython")

====================== SOLVED ===========================
BY changing the scipy version to ==0.15.1 in the requirements.txt

from deepwalk.

apuneet avatar apuneet commented on August 15, 2024 2

With following versions it worked for me, on Ubuntu 14.04
Here is the output of conda list, of the environment where deepwalk worked.
argparse 1.4.0 <pip>
Cython 0.24.1 <pip>
deepwalk 1.0.1 <pip>
futures 3.0.5 <pip>
gensim 0.10.2 <pip>
numpy 1.11.1 <pip>
openssl 1.0.2h 1
pip 8.1.2 py27_0
psutil 4.3.0 <pip>
python 2.7.12 1
readline 6.2 2
scipy 0.15.1 <pip>
setuptools 25.1.6 py27_0
six 1.10.0 <pip>
sqlite 3.13.0 0
tk 8.5.18 0
wheel 0.29.0 py27_0
zlib 1.2.8 3

from deepwalk.

Hiyorimi avatar Hiyorimi commented on August 15, 2024 1

Btw, greater version of scipy doesn't work:

$ pip install -r requirements.txt 
Requirement already satisfied (use --upgrade to upgrade): wheel>=0.23.0 in [some path]/python2.7/site-packages (from -r requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): Cython>=0.20.2 in [some path]/python2.7/site-packages (from -r requirements.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): argparse>=1.2.1 in [some path]/python2.7/site-packages (from -r requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): futures>=2.1.6 in [some path]/python2.7/site-packages (from -r requirements.txt (line 4))
Requirement already satisfied (use --upgrade to upgrade): six>=1.7.3 in [some path]/python2.7/site-packages (from -r requirements.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): gensim==0.10.2 in [some path]/python2.7/site-packages (from -r requirements.txt (line 6))
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.15.1 in [some path]/python2.7/site-packages (from -r requirements.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): psutil>=2.1.1 in [some path]/python2.7/site-packages (from -r requirements.txt (line 8))
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.2 in [some path]/python2.7/site-packages (from scipy>=0.15.1->-r requirements.txt (line 7))
$ deepwalk --input example_graphs/karate.adjlist --output karate.embeddings
Number of nodes: 34
Number of walks: 340
Data size (walks*length): 13600
Walking...
Training...
[some path]/python2.7/site-packages/gensim/models/word2vec.py:406: UserWarning: Cython compilation failed, training will be slow. Do you have Cython installed? `pip install python`
  warnings.warn("Cython compilation failed, training will be slow. Do you have Cython installed? `pip install python`")

Though, I can confirm that setting ==0.15.1 works.

from deepwalk.

Uchman21 avatar Uchman21 commented on August 15, 2024 1

For those still having this same issue, I was able to use the latest version of both gensim and scipy. But I needed to make some modifications to deepwalk/main.py and gensim/models/word2vec.py for them to be compatible. For the first I changed a function call model.save_word2vec_format to model.wv.save_word2vec_format and for the second, I changed self.wv.syn0[i] = self.seeded_vector(self.wv.index2word[i] + str(self.seed)) to self.wv.syn0[i] = self.seeded_vector(str(self.wv.index2word[i]) + str(self.seed)). This fixed it form me.

from deepwalk.

phanein avatar phanein commented on August 15, 2024

Let's see:

Yes, the cython support works fairly well on *nix systems. It definitely should speed up your training.

Under the hood, it looks like this is an issue which pops up every now and then between windows and gensim (see this gensim pull request: piskvorky/gensim#233)

If you are using the old version of gensim for deepwalk, I might suggest upgrading gensim and patching the line that crashes (see deepwalk issue #13 for a potential fix).

from deepwalk.

vikeydr avatar vikeydr commented on August 15, 2024

It works fine for me, thank you very much!

from deepwalk.

phanein avatar phanein commented on August 15, 2024

Thanks for posting your fix - I guess problems can arise when scipy and gensim have conflicting cython version dependencies.

from deepwalk.

hengqujushi avatar hengqujushi commented on August 15, 2024

same to me, greater version of scipy doesn't work:

from deepwalk.

chengjun avatar chengjun commented on August 15, 2024

Thank @Uchman21 very much. I follow your idea, and it also works for me.

  1. For the deepwalk/main.py I changed a function call model.save_word2vec_format to model.wv.save_word2vec_format
  2. For gensim/models/word2vec.py, I changed self.wv.syn0[i] = self.seeded_vector(self.wv.index2word[i] + str(self.seed)) to self.wv.syn0[i] = self.seeded_vector(str(self.wv.index2word[i]) + str(self.seed)).

from deepwalk.

veleritas avatar veleritas commented on August 15, 2024

Also confirming that editing the source files as mentioned by the above two posters solved the problem for me using the latest gensim.

Also had to modify line 16 of deepwalk/__main__.py from from skipgram import Skipgram to from .skipgram import Skipgram. I am using Python 3.5.

from deepwalk.

worm6206 avatar worm6206 commented on August 15, 2024

I don't think touching gensim's code is a good move, just make sure the elements are string, and gensim's word2vec will happily take it.

  1. like what @Uchman21 did in the deepwalk/main.py model.save_word2vec_format to model.wv.save_word2vec_format

  2. then add couple strs here and there in function random_walk from deepwalk/graph.py,

def random_walk(self, path_length, alpha=0, rand=random.Random(), start=None):
    """ Returns a truncated random walk.

        path_length: Length of the random walk.
        alpha: probability of restarts.
        start: the start node of the random walk.
    """
    G = self
    if start:
      path = [str(start)]
    else:
      # Sampling is uniform w.r.t V, and not w.r.t E
      path = [str(rand.choice(list(G.keys())))]

    while len(path) < path_length:
      cur = int(path[-1])
      if len(G[cur]) > 0:
        if rand.random() >= alpha:
          path.append(str(rand.choice(G[cur])))
        else:
          path.append(str(path[0]))
      else:
        break
    return path

from deepwalk.

aswathydiv36 avatar aswathydiv36 commented on August 15, 2024

How to edit the gensim/models/word2vec.py file?

from deepwalk.

GTmac avatar GTmac commented on August 15, 2024

@aswathydiv36 We have already updated the random walk part, so you do not need to modify gensim word2vec anymore.

from deepwalk.

aswathydiv36 avatar aswathydiv36 commented on August 15, 2024

ok thanks

from deepwalk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.