DGSDA(in_dim, hid_dim, num_classes, mode='node', num_layers=2, dropout=0.0, act=F.relu, K=8, alpha=0.05, beta=0.5, gamma=0.05, weight_decay=0.0, lr=0.004, epoch=200, device='cuda:0', batch_size=0, num_neigh=-1, verbose=2, **kwargs)
Bases: BaseGDA
Disentangled Graph Spectral Domain Adaptation (ICML-25).
| Parameters: |
|
|---|
Examples:
>>> from pygda.models import DGSDA
>>> model = DGSDA(in_dim=128, hid_dim=64, num_classes=7)
>>> model.fit(source_data, target_data)
>>> logits, labels = model.predict(test_data)
entropy_minimization_loss(output)
Compute entropy minimization loss for target domain regularization.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
The entropy minimization loss is computed as:
- Compute softmax probabilities from logits
- Calculate class-wise prediction frequencies
- Compute weighted entropy loss that penalizes uncertain predictions more heavily for classes with higher prediction frequencies
fit(source_data, target_data)
Train the DGSDA model on source and target domain data.
| Parameters: |
|
|---|
Notes
The training process includes:
-
Data Loader Setup: Creates appropriate data loaders based on the task mode (node/graph) and batch size settings.
-
Model Initialization: Initializes the DGSDA model with specified architecture parameters.
-
Optimization: Uses Adam optimizer with specified learning rate and weight decay for parameter updates.
-
Training Loop: For each epoch:
-
Processes batches of source and target data
-
Computes multi-component loss
-
Updates model parameters
-
Logs training metrics (loss, accuracy, time)
-
-
Evaluation: Computes micro-F1 score on source domain for monitoring training progress.
The method supports both node-level and graph-level tasks, though currently only node-level tasks are fully implemented.
forward_model(source_data, target_data)
Forward pass of the DGSDA model.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
The forward pass computes multiple loss components:
- Source domain cross-entropy loss for supervised learning
- Temperature parameter L1 loss between source and target domains
- Maximum Mean Discrepancy (MMD) loss for domain alignment
- Entropy minimization loss for target domain regularization
init_model(**kwargs)
Initialize the DGSDA base model.
| Parameters: |
|
|---|
| Returns: |
|
|---|
predict(data, source=False)
Make predictions on input data.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
The prediction process:
-
Model Evaluation: Sets the model to evaluation mode to disable dropout and batch normalization updates.
-
Data Processing: Uses the appropriate data loader (source or target) based on the source parameter.
-
Inference: Performs forward pass without gradient computation for efficient inference.
-
Result Aggregation: Concatenates predictions from multiple batches if the data is processed in batches.
The method automatically handles both source and target domain prediction modes, with different processing pipelines for each.
process_graph(data)
Process the input graph data.
| Parameters: |
|
|---|
Notes
This method is currently a placeholder as preprocessing is handled through the NeighborLoader and DataLoader classes during training and prediction phases.