Support initial node features in RGCN


#1

Hi all,
The example code for RGCN assumes that there are no initial features for each node, thus they made an “embedding lookup” on weights matrix, see the following code (line 86 of https://github.com/dmlc/dgl/blob/master/examples/pytorch/rgcn/layers.py )

        if self.is_input_layer:
            def msg_func(edges):
                # for input layer, matrix multiply can be converted to be
                # an embedding lookup using source node id
                embed = weight.view(-1, self.out_feat)
                index = edges.data['type'] * self.in_feat + edges.src['id']
                return {'msg': embed.index_select(0, index) * edges.data['norm']}

However, in my case, I have the initial features for each node, how to modify the code to fit that?


#2

You can use g.ndata['feat']=th.tensor(...) to set initial feature for nodes