SAGDA(in_dim, hid_dim, num_classes, mode='node', beta=1.0, alpha=1.0, num_layers=2, dropout=0.0, act=F.relu, ppmi=True, adv_dim=40, weight_decay=0.003, lr=0.004, epoch=200, device='cuda:0', batch_size=0, num_neigh=-1, verbose=2, **kwargs)

Bases: BaseGDA

SA-GDA: Spectral Augmentation for Graph Domain Adaptation (MM-23).

Parameters:
  • in_dim (int) –

    Input feature dimension.

  • hid_dim (int) –

    Hidden dimension of model.

  • num_classes (int) –

    Total number of classes.

  • mode (str, default: 'node' ) –

    Mode for node or graph level tasks. Default: node.

  • num_layers (int, default: 2 ) –

    Total number of layers in model. Default: 2.

  • dropout (float, default: 0.0 ) –

    Dropout rate. Default: 0..

  • weight_decay (float, default: 0.003 ) –

    Weight decay (L2 penalty). Default: 0.003.

  • act (callable activation function or None, default: relu ) –

    Activation function if not None. Default: torch.nn.functional.relu.

  • alpha (float, default: 1.0 ) –

    Trade-off parameter for high pass filter. Default: 1.0.

  • beta (float, default: 1.0 ) –

    Trade-off parameter for low pass filter. Default: 1.0.

  • ppmi (bool, default: True ) –

    Use PPMI matrix or not. Default: True.

  • adv_dim (int, default: 40 ) –

    Hidden dimension of adversarial module. Default: 40.

  • lr (float, default: 0.004 ) –

    Learning rate. Default: 0.004.

  • epoch (int, default: 200 ) –

    Maximum number of training epoch. Default: 200.

  • device (str, default: 'cuda:0' ) –

    GPU or CPU. Default: cuda:0.

  • batch_size (int, default: 0 ) –

    Minibatch size, 0 for full batch training. Default: 0.

  • num_neigh (int, default: -1 ) –

    Number of neighbors in sampling, -1 for all neighbors. Default: -1.

  • verbose (int, default: 2 ) –

    Verbosity mode. Range in [0, 3]. Larger value for printing out more log information. Default: 2.

  • **kwargs

    Other parameters for the model.

fit(source_data, target_data)

Train the SAGDA model on source and target domain data.

Parameters:
  • source_data (Data) –

    Source domain graph data.

  • target_data (Data) –

    Target domain graph data.

Notes

Training process consists of multiple components:

Data Handling

  • Supports both node and graph-level tasks
  • Configures appropriate data loaders
  • Handles batch processing

Model Training

  • Initializes spectral augmentation components
  • Implements adversarial domain adaptation
  • Combines multiple loss terms:

    • Classification loss on source domain
    • Domain adversarial loss with gradient reversal
    • Target entropy minimization
    • Spectral augmentation losses

Implementation Details

  • Dynamic adaptation parameter scaling
  • Graph pooling for graph-level tasks
  • Comprehensive progress monitoring
  • Flexible batch processing options
forward_model(source_data, target_data)

Forward pass placeholder.

Parameters:
  • source_data (Data) –

    Source domain graph data.

  • target_data (Data) –

    Target domain graph data.

Notes

Main forward logic is implemented in fit method to handle spectral augmentation and domain adaptation.

init_model(**kwargs)

Initialize the SAGDA base model.

Parameters:
  • **kwargs

    Additional parameters for model initialization.

Returns:
  • SAGDABase

    Initialized model with specified architecture parameters.

Notes

Configures model with:

  • Spectral augmentation parameters (alpha, beta)
  • PPMI matrix option
  • Adversarial module settings
  • Base architecture parameters (layers, dropout)
predict(data, source=False)

Make predictions on input data.

Parameters:
  • data (Data) –

    Input graph data.

  • source (bool, default: False ) –

    Whether predicting on source domain. Default: False.

Returns:
  • tuple

    Contains: - logits : torch.Tensor Model predictions. - labels : torch.Tensor True labels.

Notes

Prediction process:

  • Uses appropriate encoder based on domain
  • Applies graph pooling for graph-level tasks
  • Handles batch processing
  • Concatenates results for full predictions
process_graph(data)

Process the input graph data.

Parameters:
  • data (Data) –

    Input graph data to be processed.

Notes

Placeholder method for potential preprocessing steps:

  • Spectral feature computation
  • Graph structure augmentation
  • Feature normalization