DMGNN(in_dim, hid_dim, num_classes, num_layers=0, n_emb=128, pair_weight=0.1, step=3, dropout=0.0, act=F.relu, weight_decay=0.0, lr=0.004, epoch=200, device='cuda:0', batch_size=100, num_neigh=-1, verbose=2, **kwargs)
Bases: BaseGDA
Domain-adaptive message passing graph neural network (NN-23).
| Parameters: |
|
|---|
agg_tran_prob_mat(g, step)
Compute aggregated k-step transition probability matrix.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Implements iterative computation of transition probabilities up to k steps, with step-wise normalization.
batch_generator(data, batch_size, shuffle=True)
Generate mini-batches of data.
| Parameters: |
|
|---|
| Yields: |
|
|---|
Notes
Implements infinite batch generation with optional shuffling and aligned data handling.
batch_ppmi(batch_size, shuffle_index_s, shuffle_index_t, ppmi_s, ppmi_t)
Generate batch-wise PPMI matrices for source and target domains.
| Parameters: |
|
|---|
| Returns: |
|
|---|
compute_ppmi(a)
Compute Positive Pointwise Mutual Information matrix.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Removes self-loops
- Normalizes transition probabilities
- Computes log-based PPMI values
- Handles numerical stability
fit(source_data, target_data)
Train the DMGNN model on source and target domain data.
| Parameters: |
|
|---|
Notes
Training process consists of several key components:
Data Preprocessing
- Computes PPMI matrices for both domains
- Generates neighborhood-aware features
- Prepares one-hot encoded labels
- Concatenates direct and neighborhood features
Model Setup
- Initializes DMGNN model
- Configures Adam optimizer
- Sets up classification and domain loss functions
Training Loop
- Generates balanced source/target batches
- Updates domain adaptation parameter
-
Computes multiple loss components:
- Classification loss on labeled data
- Domain adversarial loss
- Network proximity loss
-
Enhances predictions with neighborhood information
- Tracks and logs training progress
Batch Processing
- Handles source and target domains separately
- Maintains balanced sampling
- Applies PPMI-based structural learning
- Implements dynamic batch generation
Loss Computation
- Classification loss on source domain
- Domain adaptation through adversarial training
- Neighborhood proximity preservation
- Combined loss optimization
Monitoring
- Tracks epoch-wise loss
- Computes micro-F1 score
- Logs training progress
- Measures computation time
forward_model(**kwargs)
Forward pass placeholder.
| Parameters: |
|
|---|
Notes
Main forward logic is implemented in fit method due to complex batch processing requirements.
init_model(**kwargs)
Initialize the DMGNN base model.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Configures a two-layer network with:
- Input dimension handling
- Hidden layer configuration
- Embedding dimension for adversarial learning
- Dropout regularization
- Batch processing settings
my_scale_sim_mat(w)
Compute L1 row normalization of a matrix.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Implementation details:
- Computes row sums
- Handles numerical stability with epsilon
- Prevents infinite values
- Applies row-wise normalization
nei_prox_loss(emb, a)
Calculate neighborhood proximity loss.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Computes average L2 distance between node embeddings and their neighborhood representations.
predict(data, train=False)
Make predictions on input data.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Uses stored whole-graph representations
- Combines direct and neighborhood predictions
- Handles source/target domains differently
process_graph(data)
Process input graph data to compute PPMI matrices and neighborhood features.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Processing steps:
- Converts edge index to dense adjacency
- Computes k-step transition probabilities
- Generates PPMI matrix
- Creates neighborhood feature aggregation
shuffle_aligned_list(data)
Shuffle multiple data arrays while maintaining alignment.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Ensures consistent shuffling across multiple data arrays, particularly useful for maintaining correspondence between features and labels during batch generation.