Under HeteteroGraph conv, it shows that you can add both GrapgConv and SAGEConv into the HeteroGraphConv. (HeteroGraphConv — DGL 0.8.1 documentation)
If I run GraphConv on a heterogeneous network with different feature sizes for different nodes, GraphConv doesnt complain about dimensionality, however SAGEConv does.
Example:
import dgl
import dgl.nn as dglnn
import matplotlib.pyplot as plt
import networkx as nx
import torch as th
graph_data = {
('drug', 'interacts', 'drug'): (th.tensor([0, 1]), th.tensor([1, 2])),
('drug', 'interacts', 'gene'): (th.tensor([0, 1]), th.tensor([2, 3])),
('drug', 'treats', 'disease'): (th.tensor([1]), th.tensor([2]))
}
g = dgl.heterograph(graph_data)
#g.nodes('drug')
g.nodes['drug'].data['hv'] = th.ones(3, 20)
g.nodes['disease'].data['hv'] = th.ones(3, 10)
g.nodes['gene'].data['hv'] = th.ones(4, 5)
node_features = {'drug': g.nodes['drug'].data['hv'], 'disease': g.nodes['disease'].data['hv'], 'gene': g.nodes['gene'].data['hv']}
conv = dglnn.HeteroGraphConv({
'interacts' : dglnn.GraphConv(20,10,'both'),
'treats' : dglnn.GraphConv(20,10,'both'),
},
aggregate='mean')
If I substitute GraphConv with SAGEConv it breaks with the classic issue of matrices cannot be multiplied. What I dont understand is what is so different in GraphConv that it works with different sizes. Can anyone in a bit simpler terms explain how it merges two matrices of different sizes?
Lastly, Is it correctly understood that in this example each data will be aggregated over each edge type individually, and then in the end use the aggregation function, for example “mean”.
If so, would it then not create quite a mess if you have features on very different scales (age vs height in mm vs gps coordinates). And all would then be squeezed together?