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: |
|
|---|
| Attributes: |
|
|---|
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: |
|
|---|
| Returns: |
|
|---|
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: |
|
|---|
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: |
|
|---|
| Returns: |
|
|---|
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: |
|
|---|
| Returns: |
|
|---|
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: |
|
|---|
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