dmlc / dgl

Python package built to ease deep learning on graph, on top of existing DL frameworks.
http://dgl.ai
Apache License 2.0
13.51k stars 3.02k forks source link

Bug with RGCN using wn18(NOT FB15k-237) #694

Closed rayrayraykk closed 5 years ago

rayrayraykk commented 5 years ago

🐛 Bug

I try to use RGCN in wn18 ,but i get something wrong when evaluation starts,can you help me? and it works well in FB15k-237 (has the same data format with the wn18).I wonder why this code can't work in wn18.

rgcn/dgl/examples/pytorch/rgcn/utils.py

# perturb subject
ranks_s = perturb_and_get_rank(embedding, w, o, r, s, num_entity, eval_bz) 

works well

# perturb object
ranks_o = perturb_and_get_rank(embedding, w, s, r, o, num_entity, eval_bz)

RuntimeError

To Reproduce

Steps to reproduce the behavior:

1.python link_predict.py -d wn18 > 'wn18.out'

...........
 sampled nodes: 16357
 sampled edges: 30000
 nodes: 16357, 
 edges: 30000
Done edge sampling
Epoch 0500 | Loss 0.0412 | Best MRR 0.0000 | Forward 0.0123s | Backward 0.4636s
start eval
batch 0 / 82
batch 1 / 82
batch 2 / 82
batch 3 / 82
batch 4 / 82
batch 5 / 82
batch 6 / 82
batch 7 / 82
batch 8 / 82
batch 9 / 82
batch 10 / 82
batch 11 / 82
batch 12 / 82
batch 13 / 82
batch 14 / 82
batch 15 / 82
batch 16 / 82
batch 17 / 82
batch 18 / 82
batch 19 / 82
batch 20 / 82
batch 21 / 82
batch 22 / 82
batch 23 / 82
batch 24 / 82
batch 25 / 82
batch 26 / 82
batch 27 / 82
batch 28 / 82
batch 29 / 82
batch 30 / 82
batch 31 / 82
batch 32 / 82
batch 33 / 82
batch 34 / 82
batch 35 / 82
batch 36 / 82
batch 37 / 82
batch 38 / 82
batch 39 / 82
batch 40 / 82
batch 41 / 82
batch 42 / 82
batch 43 / 82
batch 44 / 82
batch 45 / 82
batch 46 / 82
batch 47 / 82
batch 48 / 82
batch 49 / 82
batch 50 / 82
batch 51 / 82
batch 52 / 82
batch 53 / 82
batch 54 / 82
batch 55 / 82
batch 56 / 82
batch 57 / 82
batch 58 / 82
batch 59 / 82
batch 60 / 82
batch 61 / 82
batch 62 / 82
batch 63 / 82
batch 64 / 82
batch 65 / 82
batch 66 / 82
batch 67 / 82
batch 68 / 82
batch 69 / 82
batch 70 / 82
batch 71 / 82
batch 72 / 82
batch 73 / 82
batch 74 / 82
batch 75 / 82
batch 76 / 82
batch 77 / 82
batch 78 / 82
batch 79 / 82
batch 80 / 82
batch 81 / 82
batch 0 / 82
batch 1 / 82
batch 2 / 82
batch 3 / 82
batch 4 / 82
batch 5 / 82
batch 6 / 82
batch 7 / 82
batch 8 / 82
batch 9 / 82
batch 10 / 82
Traceback (most recent call last):
  File "link_predict.py", line 252, in <module>
    main(args)
  File "link_predict.py", line 189, in main
    hits=[1, 3, 10], eval_bz=args.eval_batch_size)
  File "/home/weirui_kuang/rgcn/dgl/examples/pytorch/rgcn/utils.py", line 200, in evaluate
    ranks_o = perturb_and_get_rank(embedding, w, s, r, o, num_entity, eval_bz)
  File "/home/weirui_kuang/rgcn/dgl/examples/pytorch/rgcn/utils.py", line 185, in perturb_and_get_rank
    ranks.append(sort_and_rank(score, target))
  File "/home/weirui_kuang/rgcn/dgl/examples/pytorch/rgcn/utils.py", line 162, in sort_and_rank
    indices = torch.nonzero(indices == target.view(-1, 1))
RuntimeError: Trying to resize storage that is not resizable at /pytorch/aten/src/TH/THStorageFunctions.cpp:76

Expected behavior

Environment

Additional context

rayrayraykk commented 5 years ago

And I see a similar issue:https://discuss.dgl.ai/t/runtimeerror-trying-to-resize-storage-that-is-not-resizable-at/239 he can‘t also use his own dataset when running link prediction.

VoVAllen commented 5 years ago

It seems target is an empty tensor. Could you try to print target to debug when error occurs?

jermainewang commented 5 years ago

Closed due to inactiveness. Please reopen if the issue still exists.