Logo
  • Installation
  • Introduction
  • Citing
  • Data Structures
    • Data Classes
    • Benchmark Datasets
    • Node Splitting
    • Edge Splitting
  • Real-World Data Set Descriptions
    • Directed Unsigned Real-World Data Sets
    • Signed Real-World Data Sets
  • Case Study Examples
    • Case Study on Signed Networks
    • Case Study on Directed Networks
  • External Resources
    • External Resources - Architectures
    • External Resources - Synthetic Data Generators
    • External Resources - Real-World Data Sets
  • PyTorch Geometric Signed Directed Models
    • Directed (Unsigned) Network Models and Layers
    • Signed (Directed) Network Models and Layers
    • Auxiliary Methods and Layers
  • PyTorch Geometric Signed Directed Data Generators and Data Loaders
    • Data Classes
    • Data Generators
    • Data Loaders
  • PyTorch Geometric Signed Directed Utils
    • Task-Specific Objectives and Evaluation Methods
    • Utilities and Preprocessing Methods
PyTorch Geometric Signed Directed
  • torch_geometric_signed_directed.nn.directed.MagNet_link_prediction
  • View page source

torch_geometric_signed_directed.nn.directed.MagNet_link_prediction

Classes

MagNet_link_prediction

The MagNet model for link prediction from the

Module Contents

class MagNet_link_prediction(num_features: int, hidden: int = 2, q: float = 0.25, K: int = 1, label_dim: int = 2, activation: bool = True, trainable_q: bool = False, layer: int = 2, dropout: float = 0.5, normalization: str = 'sym', cached: bool = False)

Bases: torch.nn.Module

The MagNet model for link prediction from the MagNet: A Neural Network for Directed Graphs. paper.

Parameters:
  • num_features (int) – Size of each input sample.

  • hidden (int, optional) – Number of hidden channels. Default: 2.

  • K (int, optional) – Order of the Chebyshev polynomial, i.e., Chebyshev filter size minus 1 \(K\). Default: 1.

  • q (float, optional) – Initial value of the phase parameter, 0 <= q <= 0.25. Default: 0.25.

  • label_dim (int, optional) – Number of output classes. Default: 2.

  • activation (bool, optional) – whether to use activation function or not. (default: True)

  • trainable_q (bool, optional) – whether to set q to be trainable or not. (default: False)

  • layer (int, optional) – Number of MagNetConv layers. Deafult: 2.

  • dropout (float, optional) – Dropout value. (default: 0.5)

  • normalization (str, optional) – The normalization scheme for the magnetic Laplacian (default: sym): 1. None: No normalization \(\mathbf{L} = \mathbf{D} - \mathbf{A} Hadamard \exp(i \Theta^{(q)})\) 2. "sym": Symmetric normalization \(\mathbf{L} = \mathbf{I} - \mathbf{D}^{-1/2} \mathbf{A} \mathbf{D}^{-1/2} Hadamard \exp(i \Theta^{(q)})\)

  • 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 to True in transductive learning scenarios. (default: False)

normalization = 'sym'
activation = True
Chebs
linear
dropout = 0.5
reset_parameters()
forward(real: torch.FloatTensor, imag: torch.FloatTensor, edge_index: torch.LongTensor, query_edges: torch.LongTensor, edge_weight: torch.LongTensor | None = None) → torch.FloatTensor

Making a forward pass of the MagNet node classification model.

Arg types:
  • real, imag (PyTorch Float Tensor) - Node features.

  • edge_index (PyTorch Long Tensor) - Edge indices.

  • query_edges (PyTorch Long Tensor) - Edge indices for querying labels.

  • edge_weight (PyTorch Float Tensor, optional) - Edge weights corresponding to edge indices.

Return types:
  • log_prob (PyTorch Float Tensor) - Logarithmic class probabilities for all nodes, with shape (num_nodes, num_classes).


© Copyright 2026, Yixuan He.

Built with Sphinx using a theme provided by Read the Docs.