gammagl.layers.conv.FILMConv¶
- class FILMConv(in_channels, out_channels, num_relations=1, act=ReLU())[source]¶
The FiLM graph convolutional operator from the “GNN-FiLM: Graph Neural Networks with Feature-wise Linear Modulation” paper
\[\mathbf{x}^{\prime}_i = \sum_{r \in \mathcal{R}} \sum_{j \in \mathcal{N}(i)} \sigma \left( \boldsymbol{\gamma}_{r,i} \odot \mathbf{W}_r \mathbf{x}_j + \boldsymbol{\beta}_{r,i} \right)\]where \(\boldsymbol{\beta}_{r,i}, \boldsymbol{\gamma}_{r,i} = g(\mathbf{x}_i)\) with \(g\) being a single linear layer by default. Self-loops are automatically added to the input graph and represented as its own relation type.
- Parameters:
in_channels (int, tuple) – Size of each input sample, or
-1to derive the size from the first input(s) to the forward method. A tuple corresponds to the sizes of source and target dimensionalities.out_channels (int) – Size of each output sample.
num_relations (int, optional) – Number of relations. (default:
1)act (callable, optional) – Activation function \(\sigma\). (default:
tlx.nn.ReLU())
- forward(x, edge_index)[source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- message(x, edge_index, beta, gamma, edge_weight=None)[source]¶
Function that construct message from source nodes to destination nodes.
- Parameters:
x (tensor) – input node feature.
edge_index (tensor) – edges from src to dst.
edge_weight (tensor, optional) – weight of each edge.
- Returns:
tensor – output message
Returns – the message matrix, and the shape is [num_edges, message_dim]