GraphATA(in_dim, hid_dim, num_classes, num_src_domains, K=10, momentum=0.9, num_layers=3, dropout=0.0, act=F.relu, weight_decay=0.0, lr=0.0001, epoch=200, gnn='gcn', mode='node', device='cuda:0', batch_size=0, num_neigh=-1, verbose=2, **kwargs)

Bases: BaseGDA

Aggregate to Adapt: Node-Centric Aggregation for Multi-Source-Free Graph Domain Adaptation (WWW-25).

This class implements a multi-source-free domain adaptation method for graphs using node-centric aggregation. It first trains independent source models and then adapts them to the target domain using a novel attention-based mechanism.

Parameters:
  • in_dim (int) –

    Input feature dimension.

  • hid_dim (int) –

    Hidden dimension of model.

  • num_classes (int) –

    Total number of classes.

  • num_src_domains (int) –

    Total number of source domains.

  • K (int, default: 10 ) –

    Number of nearest neighbors for memory bank. Default: 10.

  • momentum (float, default: 0.9 ) –

    Momentum coefficient for memory bank update. Default: 0.9.

  • num_layers (int, default: 3 ) –

    Total number of layers in model. Default: 3.

  • dropout (float, default: 0.0 ) –

    Dropout rate. Default: 0..

  • gnn (string, default: 'gcn' ) –

    GNN backbone type ('gcn', 'sage', 'gat', 'gin'). Default: gcn.

  • 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.

  • lr (float, default: 0.0001 ) –

    Learning rate. Default: 0.004.

  • epoch (int, default: 200 ) –

    Maximum number of training epochs. Default: 200.

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

    GPU or CPU device specification. 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]. Default: 2.

  • **kwargs

    Additional parameters for the model.

Attributes:
  • source_model_list (list) –

    List of trained source domain models.

  • graphata (GraphATABase) –

    The main adaptation model that combines source models.

  • source_loader (NeighborLoader) –

    DataLoader for source domain graphs.

  • target_loader (NeighborLoader) –

    DataLoader for target domain graph.

Notes

The training process consists of two main phases:

  • Source Domain Pretraining:

    • Initializes independent GNN models for each source domain
    • Trains each model separately on its corresponding source data
    • Stores the trained models in source_model_list
  • Target Domain Adaptation:

    • Creates a GraphATABase model using trained source models
    • Uses memory bank mechanism with K-nearest neighbors
    • Applies information maximization and classification losses
    • Updates memory features and class predictions with momentum
  • The adaptation phase employs several key components:

    • Feature bottleneck for transformation
    • Node-centric attention for feature aggregation
    • Memory bank for pseudo-label generation
    • Entropy minimization for target domain alignment

Examples:

>>> model = GraphATA(
...     in_dim=64,
...     hid_dim=32,
...     num_classes=7,
...     num_src_domains=3
... )
>>> # Train on source domains
>>> model.fit(source_data_list, target_data)
>>> # Predict on target domain
>>> logits, labels = model.predict(target_data)
entropy(input_)

Calculate entropy of input probabilities.

Parameters:
  • input_ (Tensor) –

    Input probability distribution.

Returns:
  • Tensor

    Entropy values for each input sample.

Notes

Used for information maximization loss during target domain adaptation.

fit(source_data_list, target_data)

Train the model on multiple source domains and adapt to target domain.

Parameters:
  • source_data_list (list of torch_geometric.data.Data) –

    List of source domain graph data objects.

  • target_data (Data) –

    Target domain graph data.

Notes

Training process:

  • Source Pretraining:

    • Trains independent models for each source domain
    • Stores models in source_model_list
  • Target Adaptation:

    • Initializes GraphATABase with source models
    • Creates memory banks for features and classes
    • Updates model using:

      • Information maximization loss
      • K-NN based pseudo-label loss
    • Updates memory banks with momentum

init_model(**kwargs)

Initialize source domain models.

Creates a list of GNN models, one for each source domain. Each model is initialized with the same architecture but will be trained independently on different source domains.

Parameters:
  • **kwargs (dict, default: {} ) –

    Additional keyword arguments passed to the GNNBase constructor.

Returns:
  • list

    List of initialized GNNBase models, one per source domain.

Notes

Model initialization process:

  • Creates num_src_domains independent GNNBase models

  • Each model has identical architecture with:

    • Input dimension: in_dim
    • Hidden dimension: hid_dim
    • Output classes: num_classes
    • Number of layers: num_layers
    • Dropout rate: dropout
    • GNN type: gnn ('gcn', 'sage', 'gat', or 'gin')
    • Operation mode: mode ('node' or 'graph')
  • All models are moved to the specified device

  • Models are stored in source_model_list for later use

The initialized models serve as the foundation for:

  • Independent source domain training
  • Weight extraction for the GraphATABase model
  • Knowledge transfer to the target domain
predict(data)

Make predictions on new data using adapted model.

Parameters:
  • data (Data) –

    Input graph data.

Returns:
  • tuple
    • logits : torch.Tensor Model predictions (num_nodes, num_classes)
    • labels : torch.Tensor True labels if available
Notes

Uses the adapted GraphATABase model for prediction, which combines knowledge from all source domains through attention-based aggregation.

train_source(src_idx, source_data)

Train a source domain model.

Parameters:
  • src_idx (int) –

    Index of the source domain.

  • source_data (Data) –

    Source domain graph data.

Notes

Process:

  • Initializes model and optimizer for the source domain
  • Creates data loader with specified batch size
  • Trains model using cross-entropy loss
  • Stores trained model in source_model_list[src_idx]
  • Logs training progress using micro-F1 score