A2GNN(in_dim, hid_dim, num_classes, mode='node', num_layers=3, dropout=0.0, act=F.relu, s_pnums=0, t_pnums=30, adv=False, weight=5, weight_decay=0.0, lr=0.004, epoch=200, device='cuda:0', batch_size=0, num_neigh=-1, verbose=2, **kwargs)

Bases: BaseGDA

Rethinking Propagation for Unsupervised Graph Domain Adaptation (AAAI-24).

Parameters:
  • in_dim (int) –

    Input feature dimension.

  • hid_dim (int) –

    Hidden dimension of model.

  • num_classes (int) –

    Total number of classes.

  • mode (str, default: 'node' ) –

    Mode for node or graph level tasks. Default: node.

  • num_layers (int, default: 3 ) –

    Total number of layers in model. Default: 3.

  • dropout (float, default: 0.0 ) –

    Dropout rate. Default: 0..

  • weight_decay (float, default: 0.0 ) –

    Weight decay (L2 penalty). Default: 0..

  • act (callable activation function or None, default: relu ) –

    Activation function if not None. Default: torch.nn.functional.relu.

  • s_pnums (int, default: 0 ) –

    Number of propagations for source models. Default: 0.

  • t_pnums (int, default: 30 ) –

    Number of propagations for target models. Default: 30.

  • adv (bool, default: False ) –

    Adversarial training or not. Default: False.

  • weight (int, default: 5 ) –

    Loss trade-off parameter. Default: 5.

  • lr (float, default: 0.004 ) –

    Learning rate. Default: 0.004.

  • epoch (int, default: 200 ) –

    Maximum number of training epoch. Default: 200.

  • device (str, default: 'cuda:0' ) –

    GPU or CPU. Default: cuda:0.

  • batch_size (int, default: 0 ) –

    Minibatch size, 0 for full batch training. Default: 0.

  • num_neigh (int, default: -1 ) –

    Number of neighbors in sampling, -1 for all neighbors. Default: -1.

  • verbose (int, default: 2 ) –

    Verbosity mode. Range in [0, 3]. Larger value for printing out more log information. Default: 2.

  • **kwargs

    Other parameters for the model.

fit(source_data, target_data)

Train the A2GNN model on source and target domain data.

Parameters:
  • source_data (Data) –

    Source domain graph data.

  • target_data (Data) –

    Target domain graph data.

Notes

Training process includes:

Data Preparation

  • Configures loaders for node/graph level tasks
  • Handles both full-batch and mini-batch scenarios
  • Sets up appropriate batch processing

Training Loop

  • Dynamic adaptation parameter scaling
  • Asymmetric message propagation
  • Domain adaptation through either:

    • Adversarial training
    • MMD minimization
  • Comprehensive progress monitoring

Implementation Features

  • Flexible task handling (node/graph)
  • Efficient batch processing
  • Adaptive learning mechanisms
forward_model(source_data, target_data, alpha)

Forward pass of the A2GNN model.

Parameters:
  • source_data (Data) –

    Source domain graph data.

  • target_data (Data) –

    Target domain graph data.

  • alpha (float) –

    Gradient reversal scaling parameter.

Returns:
  • tuple

    Contains: - loss : torch.Tensor Combined loss from multiple components. - source_logits : torch.Tensor Source domain predictions. - target_logits : torch.Tensor Target domain predictions.

Notes

Implements multiple components:

  • Asymmetric propagation (s_pnums vs t_pnums)
  • Classification loss on source domain
  • Domain adaptation (adversarial or MMD)
  • Feature bottleneck processing
init_model(**kwargs)

Initialize the A2GNN base model.

Parameters:
  • **kwargs

    Additional parameters for model initialization.

Returns:
  • A2GNNBase

    Initialized model with specified architecture parameters.

Notes

Configures model with:

  • Asymmetric propagation settings
  • Domain adaptation components
  • Task-specific architecture (node/graph)
  • Optional adversarial training module
predict(data, source=False)

Make predictions on input data.

Parameters:
  • data (Data) –

    Input graph data.

  • source (bool, default: False ) –

    Whether predicting on source domain. Default: False.

Returns:
  • tuple

    Contains: - logits : torch.Tensor Model predictions. - labels : torch.Tensor True labels.

Notes
  • Uses different propagation steps for source/target
  • Handles batch processing efficiently
  • Concatenates results for full predictions
  • Maintains evaluation mode consistency
process_graph(data)

Process the input graph data.

Parameters:
  • data (Data) –

    Input graph data to be processed.

Notes

Placeholder method as preprocessing is handled through:

  • Asymmetric propagation mechanisms
  • Domain-specific feature processing
  • Batch-wise data handling