torch_geometric_signed_directed.nn.directed.MagNetConv
Classes
The magnetic graph convolutional operator from the |
Module Contents
- class MagNetConv(in_channels: int, out_channels: int, K: int, q: float, trainable_q: bool, normalization: str = 'sym', cached: bool = False, bias: bool = True, **kwargs)
Bases:
torch_geometric.nn.conv.MessagePassingThe magnetic graph convolutional operator from the MagNet: A Neural Network for Directed Graphs. paper \(\mathbf{\hat{L}}\) denotes the scaled and normalized magnetic Laplacian \(\frac{2\mathbf{L}}{\lambda_{\max}} - \mathbf{I}\).
- Parameters:
in_channels (int) – Size of each input sample.
out_channels (int) – Size of each output sample.
K (int) – Order of the Chebyshev polynomial, i.e., Chebyshev filter size minus 1 \(K\).
q (float, optional) – Initial value of the phase parameter, 0 <= q <= 0.25. Default: 0.25.
trainable_q (bool, optional) – whether to set q to be trainable or not. (default:
False)normalization (str, optional) – The normalization scheme for the magnetic Laplacian (default:
sym): 1.None: No normalization \(\mathbf{L} = \mathbf{D} - \mathbf{A} \odot \exp(i \Theta^{(q)})\) 2."sym": Symmetric normalization \(\mathbf{L} = \mathbf{I} - \mathbf{D}^{-1/2} \mathbf{A} \mathbf{D}^{-1/2} \odot \exp(i \Theta^{(q)})\) odot denotes the element-wise multiplication.cached (bool, optional) – If set to
True, the layer will cache the __norm__ matrix on first execution, and will use the cached version for further executions. This parameter should only be set toTruein transductive learning scenarios. (default:False)bias (bool, optional) – If set to
False, the layer will not learn an additive bias. (default:True)**kwargs (optional) – Additional arguments of
torch_geometric.nn.conv.MessagePassing.
- in_channels
- out_channels
- normalization = 'sym'
- cached = False
- trainable_q
- weight
- reset_parameters()
- forward(x_real: torch.FloatTensor, x_imag: torch.FloatTensor, edge_index: torch.LongTensor, edge_weight: torch_geometric.typing.OptTensor = None, lambda_max: torch_geometric.typing.OptTensor = None) torch.FloatTensor
Making a forward pass of the MagNet Convolution layer.
- Arg types:
x_real, x_imag (PyTorch Float Tensor) - Node features.
edge_index (PyTorch Long Tensor) - Edge indices.
edge_weight (PyTorch Float Tensor, optional) - Edge weights corresponding to edge indices.
lambda_max (optional, but mandatory if normalization is None) - Largest eigenvalue of Laplacian.
- Return types:
out_real, out_imag (PyTorch Float Tensor) - Hidden state tensor for all nodes, with shape (N_nodes, F_out).
- message(x_j, norm)