Unverified Commit 15411d93 authored by xiang song(charlie.song)'s avatar xiang song(charlie.song) Committed by GitHub
Browse files

[Example] Fix some example after graph refactor. (#1884)



* Update cluster GCN README

We do not need to build metis right now.
We can use builtin metis.

* Fix gcmc mxnet

* Fix graphwriter
Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-68-185.ec2.internal>
parent 3e2f94ed
......@@ -261,7 +261,7 @@ class MovieLens(object):
x = x.asnumpy().astype('float32')
x[x == 0.] = np.inf
x = mx.nd.array(1. / np.sqrt(x))
return x.as_in_context(self._ctx).expand_dims(1)
return x.expand_dims(1)
user_ci = []
user_cj = []
movie_ci = []
......@@ -282,8 +282,8 @@ class MovieLens(object):
user_cj = _calc_norm(mx.nd.add_n(*user_cj))
movie_cj = _calc_norm(mx.nd.add_n(*movie_cj))
else:
user_cj = mx.nd.ones((self.num_user,), ctx=self._ctx)
movie_cj = mx.nd.ones((self.num_movie,), ctx=self._ctx)
user_cj = mx.nd.ones((self.num_user,))
movie_cj = mx.nd.ones((self.num_movie,))
graph.nodes['user'].data.update({'ci' : user_ci, 'cj' : user_cj})
graph.nodes['movie'].data.update({'ci' : movie_ci, 'cj' : movie_cj})
......
......@@ -105,6 +105,13 @@ def train(args):
count_num = 0
count_loss = 0
dataset.train_enc_graph = dataset.train_enc_graph.to(args.ctx)
dataset.train_dec_graph = dataset.train_dec_graph.to(args.ctx)
dataset.valid_enc_graph = dataset.train_enc_graph
dataset.valid_dec_graph = dataset.valid_dec_graph.to(args.ctx)
dataset.test_enc_graph = dataset.test_enc_graph.to(args.ctx)
dataset.test_dec_graph = dataset.test_dec_graph.to(args.ctx)
print("Start training ...")
dur = []
for iter_idx in range(1, args.train_max_iter):
......
......@@ -8,36 +8,10 @@ This repo reproduce the reported speed and performance maximally on Reddit and P
Dependencies
------------
- Python 3.7+(for string formatting features)
- PyTorch 1.1.0+
- metis
- PyTorch 1.5.0+
- sklearn
* install clustering toolkit: metis and its Python interface.
download and install metis: http://glaros.dtc.umn.edu/gkhome/metis/metis/download
METIS - Serial Graph Partitioning and Fill-reducing Matrix Ordering ([official website](http://glaros.dtc.umn.edu/gkhome/metis/metis/overview))
```
1) Download metis-5.1.0.tar.gz from http://glaros.dtc.umn.edu/gkhome/metis/metis/download and unpack it
2) cd metis-5.1.0
3) make config shared=1 prefix=~/.local/
4) make install
5) export METIS_DLL=~/.local/lib/libmetis.so
6) `pip install metis`
```
quick test to see whether you install metis correctly:
```
>>> import networkx as nx
>>> import metis
>>> G = metis.example_networkx()
>>> (edgecuts, parts) = metis.part_graph(G, 3)
```
## Run Experiments.
* For reddit data, you may run the following scripts
......
......@@ -98,8 +98,8 @@ def prepare_mp(g):
This is a workaround before full shared memory support on heterogeneous graphs.
"""
g.in_degree(0)
g.out_degree(0)
g.in_degrees(0)
g.out_degrees(0)
g.find_edges([0])
def compute_acc(pred, labels):
......
......@@ -148,6 +148,7 @@ class GraphTrans(nn.Module):
def forward(self, ent, ent_mask, ent_len, rel, rel_mask, graphs):
device = ent.device
graphs = graphs.to(device)
ent_mask = (ent_mask==0) # reverse mask
rel_mask = (rel_mask==0)
init_h = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment