JHGDA(in_dim, hid_dim, num_classes, num_layers=3, dropout=0.0, act=F.relu, weight_decay=0.0, share=False, sparse=False, classwise=True, pool_ratio=0.2, g_mmd=0.5, c_mmd=0.5, d_weight=0.1, ce_weight=0.1, prox_weight=0.1, cce_weight=0.1, lm_weight=0.1, ls_weight=0.1, lr=0.004, epoch=200, device='cuda:0', batch_size=0, num_neigh=-1, verbose=2, **kwargs)

Bases: BaseGDA

Improving Graph Domain Adaptation with Network Hierarchy (CIKM-23).

Parameters:
  • in_dim (int) –

    Input feature dimension.

  • hid_dim (int) –

    Hidden dimension of model.

  • num_classes (int) –

    Total number of classes.

  • num_layers (int, default: 3 ) –

    Total number of layers in model. Default: 3.

  • dropout (float, default: 0.0 ) –

    Dropout rate. Default: 0..

  • weight_decay (float, default: 0.0 ) –

    Weight decay (L2 penalty). Default: 0..

  • share (bool, default: False ) –

    Share the diffpool module or not. Default: False.

  • sparse (bool, default: False ) –

    Diffpool module sparse or not. Default: False.

  • classwise (bool, default: True ) –

    Classwise conditional shift or not. Default: True.

  • pool_ratio (float, default: 0.2 ) –

    Graph pooling ratio. Default: 0.2.

  • g_mmd (float, default: 0.5 ) –

    Global mmd weight. Default: 0.5.

  • c_mmd (float, default: 0.5 ) –

    Conditional mmd weight. Default: 0.5.

  • d_weight (float, default: 0.1 ) –

    Domain loss weight. Default: 0.1.

  • ce_weight (float, default: 0.1 ) –

    Cluster entropy weight. Default: 0.1.

  • prox_weight (float, default: 0.1 ) –

    Proximity loss weight. Default: 0.1.

  • cce_weight (float, default: 0.1 ) –

    Conditional cluster entropy weight. Default: 0.1.

  • lm_weight (float, default: 0.1 ) –

    Label matching weight. Default: 0.1.

  • ls_weight (float, default: 0.1 ) –

    Label stable weight. Default: 0.1.

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

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

  • 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 JHGDA 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 includes:

Data preparation:

  • Sets up data loaders for batch processing
  • Handles both full-batch and mini-batch scenarios
  • Stores source and target graph sizes

Model setup:

  • Initializes JHGDA model
  • Configures Adam optimizer with weight decay

Training loop:

  • Performs forward pass with hierarchical adaptation
  • Updates model parameters
  • Tracks and logs training metrics:

    • Loss values
    • Source domain accuracy
    • Training time
forward_model(source_data, target_data)

Forward pass of the JHGDA model.

Parameters:
  • source_data (Data) –

    Source domain graph data.

  • target_data (Data) –

    Target domain graph data.

Returns:
  • tuple

    Contains: - loss : torch.Tensor Combined loss from multiple components. - pred[0] : torch.Tensor Source domain predictions. - pred[1] : torch.Tensor Target domain predictions.

Notes

Computes multiple loss terms:

Source domain cross-entropy loss

Domain adaptation losses:

  • Global MMD loss across layers
  • Classwise conditional MMD loss

Hierarchical structure losses:

  • Conditional cluster entropy (cce)
  • Label matching (lm)
  • Label stability (ls)
  • Cluster entropy (ce)
  • Proximity loss (prox)
init_model(**kwargs)

Initialize the JHGDA model.

Parameters:
  • **kwargs

    Additional parameters for the JHGDABase model.

Returns:
  • JHGDABase

    Initialized model on the specified device.

Notes

Configures the base model with hierarchical graph structure parameters:

  • Pooling ratio for graph coarsening
  • Sharing settings for diffpool module
  • Sparsity options for efficiency
  • Classwise conditional adaptation settings
predict(data)

Make predictions on given data.

Parameters:
  • data (Data) –

    Input graph data.

Returns:
  • tuple

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

Notes

Uses the model's inference mode for prediction, which may involve hierarchical graph processing.

process_graph(data)

Process the input graph data.

Parameters:
  • data (Data) –

    Input graph data to be processed.

Notes

Placeholder method for graph preprocessing.