Skip to content

Commit aef41a7

Browse files
committed
Merge branch 'master' of https://github.com/snap-stanford/ogb
2 parents 53389b3 + 62f38c7 commit aef41a7

8 files changed

Lines changed: 11 additions & 19 deletions

File tree

examples/graphproppred/code2/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def decode_arr_to_seq(arr, idx2vocab):
170170
'''
171171

172172

173-
eos_idx_list = torch.nonzero(arr == len(idx2vocab) - 1) # find the position of __EOS__ (the last vocab in idx2vocab)
173+
eos_idx_list = torch.nonzero(arr == len(idx2vocab) - 1, as_tuple=False) # find the position of __EOS__ (the last vocab in idx2vocab)
174174
if len(eos_idx_list) > 0:
175175
clippted_arr = arr[: torch.min(eos_idx_list)] # find the smallest __EOS__
176176
else:

examples/lsc/mag240m/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Baseline code for MAG-240M
22

3-
Please refer to the **[OGB-LSC paper](https://arxiv.org/abs/2103.09430)** for the detailed setting.
3+
- Please refer to the **[OGB-LSC paper](https://arxiv.org/abs/2103.09430)** for the detailed setting.
4+
- Baseline code based on **[DGL](https://www.dgl.ai/)** is available **[here](https://github.com/dmlc/dgl/tree/master/examples/pytorch/ogb_lsc/MAG240M)**.
45

56
## Installation requirements
67
```
@@ -139,7 +140,7 @@ python rgnn.py --device=0 --model=rgat --evaluate
139140
| Label Propagation | 58.44 | 56.29 | 0 | --- |
140141
| SGC | 65.82 | 65.29 | 0.7M | GeForce RTX 2080 Ti (11GB GPU) |
141142
| SIGN | 66.64 | 66.09 | 3.8M | GeForce RTX 2080 Ti (11GB GPU) |
142-
| MLP+C&S | 66.98 | 66.09 | 0.5M | GeForce RTX 2080 Ti (11GB GPU) |
143+
| MLP+C&S | 66.98 | 66.18 | 0.5M | GeForce RTX 2080 Ti (11GB GPU) |
143144
| GraphSAGE | 67.32 | 66.25 | 4.9M | GeForce RTX 2080 Ti (11GB GPU) |
144145
| GAT | 67.71 | 66.63 | 4.9M | GeForce RTX 2080 Ti (11GB GPU) |
145146
| R-GraphSAGE | 70.21 | 68.94 | 12.2M | GeForce RTX 2080 Ti (11GB GPU) |

examples/lsc/pcqm4m/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Baseline code for PCQM4M-LSC
22

3-
Please refer to the **[OGB-LSC paper](https://arxiv.org/abs/2103.09430)** for the detailed setting.
3+
- Please refer to the **[OGB-LSC paper](https://arxiv.org/abs/2103.09430)** for the detailed setting.
4+
- Baseline code based on **[DGL](https://www.dgl.ai/)** is available **[here](https://github.com/dmlc/dgl/tree/master/examples/pytorch/ogb_lsc/PCQM4M)**.
45

56
## Installation requirements
67
```

examples/lsc/wikikg90m/dgl-ke-ogb-lsc/python/dglke/dataloader/KGDataset.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,7 @@ def rmap_fname(self):
222222
return 'relations.dict'
223223

224224
class KGDatasetWiki(KGDataset):
225-
'''Load a knowledge graph FB15k
226-
227-
The FB15k dataset has five files:
228-
* entities.dict stores the mapping between entity Id and entity name.
229-
* relations.dict stores the mapping between relation Id and relation name.
230-
* train.txt stores the triples in the training set.
231-
* valid.txt stores the triples in the validation set.
232-
* test.txt stores the triples in the test set.
233-
234-
The mapping between entity (relation) name and entity (relation) Id is stored as 'name\tid'.
235-
The triples are stored as 'head_nid\trelation_id\ttail_nid'.
225+
'''Load a knowledge graph wikikg
236226
'''
237227
def __init__(self, path, name='wikikg90m'):
238228
self.name = name

examples/lsc/wikikg90m/dgl-ke-ogb-lsc/python/dglke/dataloader/sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def __init__(self, dataset, args, ranks=64, has_importance=False):
339339
else:
340340
self.edge_parts = [np.arange(num_train)]
341341
self.rel_parts = [np.arange(dataset.n_relations)]
342-
self.cross_part = False
342+
self.cross_part = True
343343

344344
self.g = ConstructGraph(triples, dataset.n_entities, args)
345345

examples/lsc/wikikg90m/dgl-ke-ogb-lsc/python/dglke/train_pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def test(args, model, test_samplers, step, rank=0, mode='Test'):
198198
for sampler in test_samplers:
199199
print(sampler.num_edges, sampler.batch_size)
200200
for query, ans, candidate in tqdm(sampler, disable=not args.print_on_screen, total=ceil(sampler.num_edges/sampler.batch_size)):
201-
log = model.forward_test_wikikg(query, ans, candidate, sampler.mode, gpu_id)
201+
log = model.forward_test_wikikg(query, ans, candidate, sampler.mode, gpu_id).cpu()
202202
logs[sampler.mode].append(log)
203203
answers[sampler.mode].append(ans)
204204
print("[{}] finished {} forward".format(rank, mode))

ogb/linkproppred/evaluate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def _eval_mrr(self, y_pred_pos, y_pred_neg, type_info):
232232
if type_info == 'torch':
233233
y_pred = torch.cat([y_pred_pos.view(-1,1), y_pred_neg], dim = 1)
234234
argsort = torch.argsort(y_pred, dim = 1, descending = True)
235-
ranking_list = torch.nonzero(argsort == 0)
235+
ranking_list = torch.nonzero(argsort == 0, as_tuple=False)
236236
ranking_list = ranking_list[:, 1] + 1
237237
hits1_list = (ranking_list <= 1).to(torch.float)
238238
hits3_list = (ranking_list <= 3).to(torch.float)

ogb/lsc/wikikg90m.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def _calculate_mrr(self, correct_index, pred_top10):
206206
- pred_top10: shape (num_eval_triplets, 10)
207207
'''
208208
# extract indices where correct_index is within top10
209-
tmp = torch.nonzero(correct_index.view(-1,1) == pred_top10)
209+
tmp = torch.nonzero(correct_index.view(-1,1) == pred_top10, as_tuple=False)
210210

211211
# reciprocal rank
212212
# if rank is larger than 10, then set the reciprocal rank to 0.

0 commit comments

Comments
 (0)