# RGCN and shared weights

Hi,

I am new to this library and am trying to understand the implementation of the RGCN model.
The formula for an RGCN layer is:

h_i^{l+1} = \sigma\left(W_0^{(l)}h_i^{(l)}+\sum_{r\in R}\sum_{j\in N_i^r}\frac{1}{c_{i,r}}W_r^{(l)}h_j^{(l)}\right)

Hence, W_r for a given layer should have the same value for all nodes for a given rel_type r. However, from what I understand of the implementation in the tutorial, weight for the first layer is of the shape (num_rels, num_nodes, out) which means that each node i gets its own value W_{r_i}. Why was it implemented this way ?

Thanks in advance for any clarification

The weight for each layer always has shape: (num_rels, in_feats, out_feats). However, for the first layer, because it’s using node id as input feature and the node id here is using one-hot encoding, the input feature equals num_node.

So actually, the linear transformation using weight happens on edges (not nodes), and edges of the same type share the same weight W.

1 Like

Thanks you! I got a way better understanding of the GCN and R-GCN papers thanks to your feedbacks and more digging!

What would happen if you have a different number of features for different types of relations ? Would you define separate RGCN layers and at some point a pooling between them ?

I am trying to implement an RGCN on molecular data for the Kaggle competition Predicting Molecular Properties as a way to learn more about Pytorch and GCNs at the same time and there might clearly be different number of feature for different type of relations.