2018-04-08 DeepWalk代碼調(diào)試

代碼地址: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

測(cè)試運(yùn)行:

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)

最坑的是每次都要重新編譯

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末山孔,一起剝皮案震驚了整個(gè)濱河市涩维,隨后出現(xiàn)的幾起案子卫旱,更是在濱河造成了極大的恐慌,老刑警劉巖余掖,帶你破解...
    沈念sama閱讀 221,635評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡聂使,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,543評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門(mén)谬俄,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)柏靶,“玉大人,你說(shuō)我怎么就攤上這事溃论∈候眩” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 168,083評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵蔬芥,是天一觀(guān)的道長(zhǎng)梆靖。 經(jīng)常有香客問(wèn)我,道長(zhǎng)笔诵,這世上最難降的妖魔是什么返吻? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 59,640評(píng)論 1 296
  • 正文 為了忘掉前任,我火速辦了婚禮乎婿,結(jié)果婚禮上测僵,老公的妹妹穿的比我還像新娘。我一直安慰自己谢翎,他們只是感情好捍靠,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,640評(píng)論 6 397
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著森逮,像睡著了一般榨婆。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上褒侧,一...
    開(kāi)封第一講書(shū)人閱讀 52,262評(píng)論 1 308
  • 那天良风,我揣著相機(jī)與錄音谊迄,去河邊找鬼。 笑死烟央,一個(gè)胖子當(dāng)著我的面吹牛统诺,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播疑俭,決...
    沈念sama閱讀 40,833評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼粮呢,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了钞艇?” 一聲冷哼從身側(cè)響起啄寡,我...
    開(kāi)封第一講書(shū)人閱讀 39,736評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎香璃,沒(méi)想到半個(gè)月后这难,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,280評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡葡秒,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,369評(píng)論 3 340
  • 正文 我和宋清朗相戀三年姻乓,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片眯牧。...
    茶點(diǎn)故事閱讀 40,503評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡蹋岩,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出学少,到底是詐尸還是另有隱情剪个,我是刑警寧澤,帶...
    沈念sama閱讀 36,185評(píng)論 5 350
  • 正文 年R本政府宣布版确,位于F島的核電站扣囊,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏绒疗。R本人自食惡果不足惜侵歇,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,870評(píng)論 3 333
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望吓蘑。 院中可真熱鬧惕虑,春花似錦、人聲如沸磨镶。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 32,340評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)琳猫。三九已至伟叛,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間脐嫂,已是汗流浹背痪伦。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,460評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工侄榴, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人网沾。 一個(gè)月前我還...
    沈念sama閱讀 48,909評(píng)論 3 376
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像蕊爵,于是被迫代替她去往敵國(guó)和親辉哥。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,512評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容