SOGA(in_dim, hid_dim, num_classes, num_layers=3, dropout=0.0, act=F.relu, num_negative_samples=5, num_positive_samples=2, struct_lambda=1.0, neigh_lambda=1.0, weight_decay=0.0, lr=0.004, epoch=200, gnn='gcn', device='cuda:0', batch_size=0, num_neigh=-1, verbose=2, **kwargs)
Bases: BaseGDA
Source Free Graph Unsupervised Domain Adaptation (WSDM-24).
| Parameters: |
|
|---|
NCE_loss(outputs, center_nodes, positive_samples, negative_samples)
Compute Noise Contrastive Estimation loss.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Implements InfoNCE-style contrastive loss
- Handles both structural and neighborhood contrasts
- Uses temperature-scaled dot product similarity
div(softmax_output)
Calculate diversity loss.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Computes negative entropy of mean predictions
- Encourages uniform class distribution
ent(softmax_output)
Calculate mean entropy across samples.
| Parameters: |
|
|---|
| Returns: |
|
|---|
entropy(x)
Calculate entropy of probability distribution.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Handles numerical stability with epsilon
- Computes per-sample entropy
fit(source_data, target_data)
Train the SOGA model on source and target domains.
| Parameters: |
|
|---|
Notes
Training process:
Source Pretraining
- Supervised training on source domain
- Classification loss optimization
Target Adaptation
- Unsupervised adaptation
- NCE loss for structure and neighborhood
- Information maximization
forward_model(data, **kwargs)
Forward pass placeholder for SOGA model.
| Parameters: |
|
|---|
Notes
Placeholder method as SOGA implements custom forward logic through:
- Source domain training in train_source()
- Target domain adaptation in train_target()
- Prediction using adapted model in predict()
- NCE-based contrastive learning
init_model(**kwargs)
Initialize the SOGA base model.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Configures model with:
- GNN backbone architecture
- NCE loss parameters
- Sampling configurations
- Model dimensions and dropout
predict(data)
Make predictions on target domain data.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
- Evaluates model in inference mode
- Handles batch processing
- Concatenates predictions for full graph
process_graph(data)
Process input graph data.
| Parameters: |
|
|---|
Notes
Placeholder method as graph processing is handled through:
- Positive/negative sample generation
- Neighborhood structure analysis
- Information maximization computations
- Batch-wise data handling in training methods
train_source(optimizer)
Train the model on source domain data.
| Parameters: |
|
|---|
Notes
- Performs supervised training on source domain
- Uses cross-entropy loss for classification
- Tracks training metrics and loss
- Handles batch processing if specified
train_target(target_data, optimizer)
Adapt the model to target domain.
| Parameters: |
|
|---|
Notes
Implementation includes:
- Initialization of target domain samples
- NCE loss computation for structure and neighborhood
- Information maximization loss
- Combined optimization objective