In the simplified example of ACM dataset as shown here in DGL website, a heterogeneous graph of author and paper is created and the paper nodes are assigned labels based on the conference they are published i.e. KDD, ICML, VLDB
The author paper data is given as a matrix where a value of 1 exists when an author writes a paper. Each paper has multiple authors. If instead of assigning a value of 1 to all the authors who write a paper suppose a fractional value is assigned [0~1] to indicate the contribution for author paper data and I want to assign them as edge weights. Should I add them by doing the following
G.edata['h'] = {('author', 'writing', 'paper'): torch.rand(G.num_edges('writing'),1),
('paper', 'written-by', 'author'): torch.rand(G.num_edges('written-by'),1)}
I used torch.rand as an example but I will be taking in the values from the new PapervAuthor matrix. Also do I need to make any changes to the HeterRGCNLayer because of this modification? I am putting the code here for ease of access
class HeteroRGCNLayer(nn.Module):
def __init__(self, in_size, out_size, etypes):
super(HeteroRGCNLayer, self).__init__()
self.weight = nn.ModuleDict({
name : nn.Linear(in_size, out_size) for name in etypes})
def forward(self, G, feat_dict):
funcs = {}
for srctype, etype, dsttype in G.canonical_etypes:
Wh = self.weight[etype](feat_dict[srctype])
G.nodes[srctype].data['Wh_%s' % etype] = Wh
funcs[etype] = (fn.copy_u('Wh_%s' % etype, 'm'), fn.mean('m', 'h'))
G.multi_update_all(funcs, 'sum')
return {ntype : G.nodes[ntype].data['h'] for ntype in G.ntypes}