-
I'm having trouble using HeteroBatchNorm I don't quite understand how the forward function works and in particular the type_vec parameter how can I create it? Is there an example for the use of HeteroBatchNorm and HeteroLayerNorm my code looks like this:
Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
x = ... [num_nodes, num_features]
type_vec = [0, 0, 1, 1, 1, ...] # First two nodes belong to node type 0, etc In your case, the output is a dictionary, so something like torch.nn.ModuleDict({node_type: BatchNorm(64) for node_type in node_types})
x_dict = {node_type: norm_dict[node_type](x) for node_type, x, in x_dict.items()} already does the job. |
Beta Was this translation helpful? Give feedback.
-
okay thanks in which context do i usw |
Beta Was this translation helpful? Give feedback.
You can use it whenever you don't want to utilize for-loops and do message passing all at once. This can have some advantages when number of node types or number of edge types get really big. For example, you can use
RGCNConv
together withHeteroBatchNorm
.