question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Default value of `num_bases` can crash RelGraphConv module

See original GitHub issue

🐛 Bug

As stated in the Doc, the optional input argument num_bases of RelGraphConv is None by default. However, if we actually set num_bases=None or simply not specify it, the code will crash…

It crashed because when num_bases=None, it will raise the value error at here: https://github.com/dmlc/dgl/blob/2cf05c53420546443a267d91ec624887d0078278/python/dgl/nn/pytorch/linear.py#L93-L94

We may need to fix the doc and RelGraphConv interface, to make it clear that num_bases is not optional (definitely not None) and has to be specified as a positive integer<=num. relations .

To Reproduce

Step(s) to reproduce the behavior:

  1. whenever construct RelGraphConv as: conv = RelGraphConv(in_feat, out_feat, num_rels, num_bases=None) or conv = RelGraphConv(in_feat, out_feat, num_rels)

Output stack:

Traceback (most recent call last):
  File "entity.py", line 93, in <module>
    model = RGCN(in_size, 16, out_size, num_rels).to(device)
  File "entity.py", line 15, in __init__
    self.conv1 = RelGraphConv(h_dim, h_dim, num_rels, regularizer='basis',
  File "/opt/conda/lib/python3.8/site-packages/dgl/nn/pytorch/conv/relgraphconv.py", line 105, in __init__
    self.linear_r = TypedLinear(in_feat, out_feat, num_rels, regularizer, num_bases)
  File "/opt/conda/lib/python3.8/site-packages/dgl/nn/pytorch/linear.py", line 94, in __init__
    raise ValueError('Missing "num_bases" for basis regularization.')
ValueError: Missing "num_bases" for basis regularization.

Expected behavior

It should not crash with a default value.

Environment

  • DGL Version (e.g., 1.0): 0.9
  • Backend Library & Version (e.g., PyTorch 0.4.1, MXNet/Gluon 1.3): Pytorch 1.13
  • OS (e.g., Linux): Linux
  • How you installed DGL (conda, pip, source): source

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chang-lcommented, Aug 1, 2022

Right, this is what I understood. I will resolve this with a bugfix PR.

0reactions
mufeilicommented, Aug 1, 2022

As @jermainewang said, num_bases should also be optional. If it is not provided, it should be set to num_rels.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RelGraphConv — DGL 0.8.2post1 documentation - DGL Docs
Default applies no regularization. num_bases (int, optional) – Number of bases. Needed when regularizer is specified. Default: None ...
Read more >
dgl/relgraphconv.py at master · dmlc/dgl - GitHub
Python package built to ease deep learning on graph, on top of existing DL frameworks. - dgl/relgraphconv.py at master · dmlc/dgl.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found