canonical_etypes should be used in HeteroGraphConv
🐛 Bug
Trying to train this kind of graphs:
metagraph=[('tweet', 'url', 'links'), ('tweet', 'user', 'mentions'), ('tweet', 'hashtag', 'tags'), ('user', 'url', 'links'), ('user', 'user', 'mentions'), ('user', 'hashtag', 'tags'), ('user', 'tweet', 'tweets')])
leads to error:
dgl._ffi.base.DGLError: Edge type "links" is ambiguous. Please use canonical edge type in the form of (srctype, etype, dsttype)
but HeteroGraphConv has as input:
mods : dict[str, nn.Module] Modules associated with every edge types.
So canonical types cannot be used.
It seems to be impossible to use HeteroGraphConv in case the same relation is used between different types of nodes.
see also #3435
To Reproduce
Steps to reproduce the behavior:
- Create a graph with the same relation name between more than one couple of nodes, such as ('tweet', 'url', 'links'), ('user', 'url', 'links'),
- Create a heterograph with something like
HeteroGraphConv({
name: GraphConv(in_size, out_size) for name in etypes
})
- Call the forward function of HeteroGraphConv
Expected behavior
It should be possible to specify canonical etypes as an input to HeteroGraphConv, and therefore remove the ambiguity
Environment
- DGL Version (e.g., 1.0): dgl==0.6.0
Additional context
I also encounterd this error just a few minutes ago.
I think there are two use cases:
- Use the same NN module for
('tweet', 'url', 'links')and('user', 'url', 'links')as a way of parameter sharing/regularization. - Use different NN modules for
('tweet', 'url', 'links')and('user', 'url', 'links').
I believe both use cases are valid and we should extend HeteroGraphConv to support them. I've marked this as a feature request to be implemented.
Thank you very much for this fix, is this fix also going to be included into the cuda versions, for example dgl-cu111?
It is currently not in the latest v0.9.1 release but will be in the nightly build after a day.