Implementation and experiments of graph embedding algorithms.
data/wiki | ||
examples | ||
ge | ||
pics | ||
.gitattributes | ||
.gitignore | ||
LICENSE | ||
README.md | ||
setup.py |
GraphEmbedding
Method
Model | Paper | Note |
---|---|---|
DeepWalk | [KDD 2014]DeepWalk: Online Learning of Social Representations | 【Graph Embedding】DeepWalk:算法原理,实现和应用 |
LINE | [WWW 2015]LINE: Large-scale Information Network Embedding | 【Graph Embedding】LINE:算法原理,实现和应用 |
How to run examples
- clone the repo and make sure you have installed
tensorflow
ortensorflow-gpu
on your local machine. - run following commands
python setup.py install
cd examples
python deepwalk_wiki.py
Usage
The design and implementation follows simple principles(graph in,embedding out) as much as possible.
Input format
we use networkx
to create graphs.The input of networkx graph is as follows:
node1 node2 <edge_weight>
DeepWalk
G = nx.read_edgelist('../data/wiki/Wiki_edgelist.txt',create_using=nx.DiGraph(),nodetype=None,data=[('weight',int)])# Read graph
model = DeepWalk(G,walk_length=10,num_walks=80,workers=1)#init model
model.train(window_size=5,iter=3)# train model
embeddings = model.get_embeddings()# get embedding vectors
LINE
G = nx.read_edgelist('../data/wiki/Wiki_edgelist.txt',create_using=nx.DiGraph(),nodetype=None,data=[('weight',int)])#read graph
model = LINE(G,embedding_size=128,order='second') #init model,order can be ['first','second','all']
model.train(batch_size=1024,epochs=50,verbose=2)# train model
embeddings = model.get_embeddings()# get embedding vectors