DGDA(in_dim, hid_dim, num_classes, num_layers=3, dropout=0.0, act=F.relu, dec_dim=64, d_dim=64, y_dim=256, m_dim=128, recons_w=1.0, beta=0.5, ent_w=1.0, d_w=1.0, y_w=1.0, m_w=0.1, edge_drop_rate=0.1, edge_add_rate=0.1, weight_decay=0.0005, lr=0.001, epoch=400, device='cuda:0', batch_size=0, num_neigh=-1, verbose=2, **kwargs)
Bases: BaseGDA
Graph Domain Adaptation: A Generative View (TKDD-24).
| Parameters: |
|
|---|
DGDA_loss(res, labels, adj, domain, manipulate=False, dadj=None)
Compute the combined loss for DGDA training.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Combines multiple loss terms:
- Graph reconstruction loss
- KL divergence for three latent spaces
- Classification loss (source only)
- Domain adversarial loss
- Maximum entropy regularization
drop_edges(adj, drop_rate=0.0, add_rate=0.0)
Perform edge manipulation for data augmentation.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Maintains graph symmetry
- Preserves self-loops
- Controls sparsity level
fit(source_data, target_data)
Train the DGDA model on source and target domain data.
| Parameters: |
|
|---|
Notes
Training process consists of multiple stages:
Pretraining Stage
- DeepWalk pretraining for source domain
- DeepWalk pretraining for target domain
- Embedding initialization
Main Training Loop
- Processes original graphs
-
Computes multiple losses:
- Reconstruction loss
- KL divergence for latent spaces
- Classification loss
- Domain adversarial loss
- Entropy maximization
Manipulation Training
- Edge dropping and addition
- Additional reconstruction objectives
- Structure preservation
forward_model(source_data, target_data)
Forward pass of the DGDA model.
| Parameters: |
|
|---|
Notes
Placeholder method as the main forward logic is implemented in the fit method, which handles:
- Multiple latent space encoding
- Graph reconstruction
- Domain discrimination
- Classification
- Edge manipulation
The complex nature of DGDA's generative approach requires integrated processing of both domains with access to the full training context, hence implementation in fit method.
init_model(**kwargs)
Initialize the DGDA base model.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Configures model with:
- Encoder-decoder architecture
- Multiple latent spaces (domain, semantic, random)
- Pretrained embeddings for both domains
- GCN backbone for feature extraction
kl_loss(mu, lv)
Compute KL divergence loss for variational inference.
| Parameters: |
|
|---|
| Returns: |
|
|---|
max_entropy(x)
Compute maximum entropy regularization.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Encourages uniform distribution in latent spaces.
predict(data)
Make predictions on target domain data.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Uses stored graph structure and features for consistent prediction.
process_graph(data)
Process the input graph data.
| Parameters: |
|
|---|
Notes
Placeholder method for potential preprocessing steps:
- Graph structure normalization
- Feature preprocessing
- Edge weight computation
- Adjacency matrix preparation
Currently not implemented as preprocessing is handled in the fit method through DeepWalk pretraining and edge manipulation procedures.
recons_loss(recons, adjs)
Compute weighted binary cross-entropy loss for graph reconstruction.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Handles class imbalance with positive edge weighting
- Normalizes based on graph size
- Ensures non-negative loss values