I am multiplying edge weights onto the messages on each edge. But, the problem is it is not returning embedding for “user” node. Could you please suggest where the problem might be?
hetero_graph = dgl.heterograph({
('user', 'click', 'item'): (click_src, click_dst),
('item', 'similar-to', 'item'): (similar_to_src, similar_to_dst)})
hetero_graph.nodes['user'].data['feature'] = user_feats
hetero_graph.nodes['item'].data['feature'] = item_feats
hetero_graph.edges['click'].data['weight'] = click_weight
hetero_graph.edges['similar-to'].data['weight'] = similar_to_weight
class RGCN(nn.Module):
def __init__(self, in_feats, hid_feats, out_feats, canonical_etypes):
super().__init__()
self.conv1 = dglnn.HeteroGraphConv({
etype : dglnn.GraphConv(in_feats, hid_feats)
for utype, etype, vtype in canonical_etypes}, aggregate='sum')
self.conv2 = dglnn.HeteroGraphConv({
etype : dglnn.GraphConv(hid_feats, out_feats)
for _, etype, _ in canonical_etypes}, aggregate='sum')
def forward(self, graph, inputs):
edge_weights = {
'click': {'edge_weight': graph.edata['weight'][('user', 'click', 'item')]},
'similar-to': {'edge_weight': graph.edata['weight'][('item', 'similar-to', 'item')]},
}
h = self.conv1(graph, inputs, mod_kwargs=edge_weights) # here it returns embedding only for "item" node
h = {k: F.relu(v) for k, v in h.items()}
h = self.conv2(graph, h, mod_kwargs=edge_weights)
return h