Giter Site home page Giter Site logo

metapath2vec's Introduction

metapath2vec with tensorflow

This repo contains an implementation of metapath2vec using tensorflow.

main reference appeared at KDD 2017: metapath2vec:

Please use the author's implementation for formal experiments!!

I just wrote this for myself in order to learn how the algorithm works. I haven't tested on a big network or even checked if I can reproduce the reported performance, so be careful when you use it.... (I mean there might be a bug :) ). The author 's implementation is available here: https://ericdongyx.github.io/metapath2vec/m2v.html.

Requirements

I recommend you to install Anaconda and then tensorflow.

How to use.

See help for the information. It should be self-contained.

python main.py --help

You need to provide two files: a text file that has node type information, and text files that has paths generated by random walks guided by a meta path. See data/test_data to find sample txts. Note that you have to generate meta-path guided random walks by yourself.

How to train.

learn embeddings using the random walks

python main.py --walks ./data/test_data/random_walks.txt --types ./data/test_data/node_type_mapings.txt --log ./log --negative-samples 5 --window 1 --epochs 100 --care-type 0
python main.py --walks ./data/test_data/random_walks.txt --types ./data/test_data/node_type_mapings.txt --log ./log --negative-samples 1 --window 1 --epochs 100 --care-type 1
tensorboard --logdir=./log/

how to load the learned embeddings

import numpy as np
import json
index2nodeid = json.load(open("./log/index2nodeid.json"))
index2nodeid = {int(k):v for k,v in index2nodeid.items()}
nodeid2index = {v:int(k) for k,v in index2nodeid.items()}
node_embeddings = np.load("./log/node_embeddings.npz")['arr_0']

#node embeddings of "yi"
node_embeddings[nodeid2index["yi"]]

To do list

  • Make the batch size more than 1.

metapath2vec's People

Contributors

apple2373 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metapath2vec's Issues

How the get meta path?

Thanks for provide this tf implementation. I'm confused about the meta path. If I have a heterogeneous Network with only two kinds of nodes, denote A and B. Is there only two kinds meta path A-B-A and B-A-B?

pros with node embeddings

Hi, thanks for your amazing work. I wonder what's the meaning of the node embedding and index2node, it's the relation computed by the model?

metapath strategy: strictly or non strictly?

for v ∈ V do
MP = MetaPathRandomWalk(G, P, v, l) ;
X = HeterogeneousSkipGram(X, k, MP) ;
end
if the type of v is not equal to the first of your input metapath P, then you will skip it and use the next node v or choose the neighborhood node of v in its appropriate type in P. For example, the metapath is "author-conf-author" and node v is a conf, i wonder should i choose one author node of conf v according the partial path "conf-author" of the metapath P? or we skip the node v until we get an author node to match the metapath "author-conf-author" strictly ?
I appreciate your answer on it, Thanks!

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.