2018-04-08 DeepWalk代码调试

代码地址:https://github.com/phanein/deepwalk

安装步骤:
1.cd deepwalk

2.pip install -r requirements.txt

3.python setup.py install

lijuncheng@lijunchengdeMacBook-Pro ~/Desktop/DeepWalk/代码/deepwalk/deepwalk (master*) $ cd ..
lijuncheng@lijunchengdeMacBook-Pro ~/Desktop/DeepWalk/代码/deepwalk (master*) $ pip install -r requirements.txt
Requirement already satisfied: wheel>=0.23.0 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 1))
Requirement already satisfied: Cython>=0.20.2 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 2))
Collecting argparse>=1.2.1 (from -r requirements.txt (line 3))
  Downloading argparse-1.4.0-py2.py3-none-any.whl
Collecting futures>=2.1.6 (from -r requirements.txt (line 4))
  Downloading futures-3.1.1.tar.gz
Requirement already satisfied: six>=1.7.3 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 5))
Requirement already satisfied: gensim>=1.0.0 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 6))
Requirement already satisfied: scipy>=0.15.0 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 7))
Requirement already satisfied: psutil>=2.1.1 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 8))
Requirement already satisfied: numpy>=1.11.3 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: smart-open>=1.2.1 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: boto3 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: boto>=2.32 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: requests in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: bz2file in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: botocore<1.11.0,>=1.10.2 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from boto3->smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from boto3->smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from boto3->smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from requests->smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: idna<2.7,>=2.5 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from requests->smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from requests->smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: certifi>=2017.4.17 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from requests->smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: python-dateutil<2.7.0,>=2.1 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from botocore<1.11.0,>=1.10.2->boto3->smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Requirement already satisfied: docutils>=0.10 in /Users/lijuncheng/anaconda3/lib/python3.6/site-packages (from botocore<1.11.0,>=1.10.2->boto3->smart-open>=1.2.1->gensim>=1.0.0->-r requirements.txt (line 6))
Building wheels for collected packages: futures
  Running setup.py bdist_wheel for futures ... done
  Stored in directory: /Users/lijuncheng/Library/Caches/pip/wheels/ad/79/48/b32521764d59b16fd1bc0ffd5862f6d3bf770c7d73ea1fb12a
Successfully built futures
Installing collected packages: argparse, futures
Successfully installed argparse-1.4.0 futures-3.1.1
lijuncheng@lijunchengdeMacBook-Pro ~/Desktop/DeepWalk/代码/deepwalk (master*) $ python setup.py install
running install
running bdist_egg
running egg_info
creating deepwalk.egg-info
writing deepwalk.egg-info/PKG-INFO
writing dependency_links to deepwalk.egg-info/dependency_links.txt
writing entry points to deepwalk.egg-info/entry_points.txt
writing requirements to deepwalk.egg-info/requires.txt
writing top-level names to deepwalk.egg-info/top_level.txt
writing manifest file 'deepwalk.egg-info/SOURCES.txt'
reading manifest file 'deepwalk.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
writing manifest file 'deepwalk.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/deepwalk
copying deepwalk/graph.py -> build/lib/deepwalk
copying deepwalk/__init__.py -> build/lib/deepwalk
copying deepwalk/skipgram.py -> build/lib/deepwalk
copying deepwalk/walks.py -> build/lib/deepwalk
copying deepwalk/__main__.py -> build/lib/deepwalk
creating build/bdist.macosx-10.7-x86_64
creating build/bdist.macosx-10.7-x86_64/egg
creating build/bdist.macosx-10.7-x86_64/egg/deepwalk
copying build/lib/deepwalk/graph.py -> build/bdist.macosx-10.7-x86_64/egg/deepwalk
copying build/lib/deepwalk/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/deepwalk
copying build/lib/deepwalk/skipgram.py -> build/bdist.macosx-10.7-x86_64/egg/deepwalk
copying build/lib/deepwalk/walks.py -> build/bdist.macosx-10.7-x86_64/egg/deepwalk
copying build/lib/deepwalk/__main__.py -> build/bdist.macosx-10.7-x86_64/egg/deepwalk
byte-compiling build/bdist.macosx-10.7-x86_64/egg/deepwalk/graph.py to graph.cpython-36.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/deepwalk/__init__.py to __init__.cpython-36.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/deepwalk/skipgram.py to skipgram.cpython-36.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/deepwalk/walks.py to walks.cpython-36.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/deepwalk/__main__.py to __main__.cpython-36.pyc
creating build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying deepwalk.egg-info/PKG-INFO -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying deepwalk.egg-info/SOURCES.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying deepwalk.egg-info/dependency_links.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying deepwalk.egg-info/entry_points.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying deepwalk.egg-info/not-zip-safe -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying deepwalk.egg-info/requires.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying deepwalk.egg-info/top_level.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
creating dist
creating 'dist/deepwalk-1.0.3-py3.6.egg' and adding 'build/bdist.macosx-10.7-x86_64/egg' to it
removing 'build/bdist.macosx-10.7-x86_64/egg' (and everything under it)
Processing deepwalk-1.0.3-py3.6.egg
creating /Users/lijuncheng/anaconda3/lib/python3.6/site-packages/deepwalk-1.0.3-py3.6.egg
Extracting deepwalk-1.0.3-py3.6.egg to /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Adding deepwalk 1.0.3 to easy-install.pth file
Installing deepwalk script to /Users/lijuncheng/anaconda3/bin

Installed /Users/lijuncheng/anaconda3/lib/python3.6/site-packages/deepwalk-1.0.3-py3.6.egg
Processing dependencies for deepwalk==1.0.3
Searching for psutil==5.4.0
Best match: psutil 5.4.0
Adding psutil 5.4.0 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for scipy==0.19.1
Best match: scipy 0.19.1
Adding scipy 0.19.1 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for gensim==3.4.0
Best match: gensim 3.4.0
Adding gensim 3.4.0 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for six==1.11.0
Best match: six 1.11.0
Adding six 1.11.0 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for futures==3.1.1
Best match: futures 3.1.1
Adding futures 3.1.1 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for argparse==1.4.0
Best match: argparse 1.4.0
Adding argparse 1.4.0 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for Cython==0.26.1
Best match: Cython 0.26.1
Adding Cython 0.26.1 to easy-install.pth file
Installing cygdb script to /Users/lijuncheng/anaconda3/bin
Installing cython script to /Users/lijuncheng/anaconda3/bin
Installing cythonize script to /Users/lijuncheng/anaconda3/bin

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for wheel==0.30.0
Best match: wheel 0.30.0
Adding wheel 0.30.0 to easy-install.pth file
Installing wheel script to /Users/lijuncheng/anaconda3/bin

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for smart-open==1.5.7
Best match: smart-open 1.5.7
Adding smart-open 1.5.7 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for numpy==1.14.0
Best match: numpy 1.14.0
Adding numpy 1.14.0 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for boto3==1.7.2
Best match: boto3 1.7.2
Adding boto3 1.7.2 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for bz2file==0.98
Best match: bz2file 0.98
Adding bz2file 0.98 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for boto==2.48.0
Best match: boto 2.48.0
Adding boto 2.48.0 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for requests==2.18.4
Best match: requests 2.18.4
Adding requests 2.18.4 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for s3transfer==0.1.13
Best match: s3transfer 0.1.13
Adding s3transfer 0.1.13 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for botocore==1.10.2
Best match: botocore 1.10.2
Adding botocore 1.10.2 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for jmespath==0.9.3
Best match: jmespath 0.9.3
Adding jmespath 0.9.3 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for certifi==2018.1.18
Best match: certifi 2018.1.18
Adding certifi 2018.1.18 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for urllib3==1.22
Best match: urllib3 1.22
Adding urllib3 1.22 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for idna==2.6
Best match: idna 2.6
Adding idna 2.6 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for chardet==3.0.4
Best match: chardet 3.0.4
Adding chardet 3.0.4 to easy-install.pth file
Installing chardetect script to /Users/lijuncheng/anaconda3/bin

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for docutils==0.14
Best match: docutils 0.14
Adding docutils 0.14 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Searching for python-dateutil==2.6.1
Best match: python-dateutil 2.6.1
Adding python-dateutil 2.6.1 to easy-install.pth file

Using /Users/lijuncheng/anaconda3/lib/python3.6/site-packages
Finished processing dependencies for deepwalk==1.0.3
lijuncheng@lijunchengdeMacBook-Pro ~/Desktop/DeepWalk/代码/deepwalk (master*) $

修改两处代码

#from . import graph
import deepwalk.graph as graph
#from . import walks as serialized_walks
import deepwalk.walks as serialized_walks
from gensim.models import Word2Vec
from .skipgram import Skipgram

测试运行:

lijuncheng@lijunchengdeMacBook-Pro ~/Desktop/DeepWalk/代码/deepwalk (master*) $
deepwalk --help
usage: deepwalk [-h] [--debug] [--format FORMAT] --input [INPUT] [-l LOG]
                [--matfile-variable-name MATFILE_VARIABLE_NAME]
                [--max-memory-data-size MAX_MEMORY_DATA_SIZE]
                [--number-walks NUMBER_WALKS] --output OUTPUT
                [--representation-size REPRESENTATION_SIZE] [--seed SEED]
                [--undirected UNDIRECTED] [--vertex-freq-degree]
                [--walk-length WALK_LENGTH] [--window-size WINDOW_SIZE]
                [--workers WORKERS]

optional arguments:
  -h, --help            show this help message and exit
  --debug               drop a debugger if an exception is raised. (default:
                        False)
  --format FORMAT       File format of input file (default: adjlist)
  --input [INPUT]       Input graph file (default: None)
  -l LOG, --log LOG     log verbosity level (default: INFO)
  --matfile-variable-name MATFILE_VARIABLE_NAME
                        variable name of adjacency matrix inside a .mat file.
                        (default: network)
  --max-memory-data-size MAX_MEMORY_DATA_SIZE
                        Size to start dumping walks to disk, instead of
                        keeping them in memory. (default: 1000000000)
  --number-walks NUMBER_WALKS
                        Number of random walks to start at each node (default:
                        10)
  --output OUTPUT       Output representation file (default: None)
  --representation-size REPRESENTATION_SIZE
                        Number of latent dimensions to learn for each node.
                        (default: 64)
  --seed SEED           Seed for random walk generator. (default: 0)
  --undirected UNDIRECTED
                        Treat graph as undirected. (default: True)
  --vertex-freq-degree  Use vertex degree to estimate the frequency of nodes
                        in the random walks. This option is faster than
                        calculating the vocabulary. (default: False)
  --walk-length WALK_LENGTH
                        Length of the random walk started at each node
                        (default: 40)
  --window-size WINDOW_SIZE
                        Window size of skipgram model. (default: 5)
  --workers WORKERS     Number of parallel processes. (default: 1)

最坑的是每次都要重新编译

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,736评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,167评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,442评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,902评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,302评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,573评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,847评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,562评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,260评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,531评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,021评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,367评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,016评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,068评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,827评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,610评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,514评论 2 269

推荐阅读更多精彩内容