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

Bases: BaseGDA

Unsupervised Domain Adaptive Graph Convolutional Networks (WWW-20).

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: 3.

  • 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.

  • 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: 300 ) –

    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 UDAGCN model.

Parameters:
  • source_data (Data) –

    Source domain graph data.

  • target_data (Data) –

    Target domain graph data.

Notes

Training process includes:

  • Setting up data loaders for both domains
  • Initializing model components
  • Training with mini-batch strategy
  • Gradually increasing domain adaptation strength
  • Optimizing classification and domain adaptation objectives
forward_model(source_data, target_data, alpha, epoch)

Forward pass of the model.

Parameters:
  • source_data (Data) –

    Source domain graph data.

  • target_data (Data) –

    Target domain graph data.

  • alpha (float) –

    Gradient reversal scaling parameter.

  • epoch (int) –

    Current training epoch.

Returns:
  • tuple

    Contains: - loss : torch.Tensor Combined loss from classification, domain adaptation, and entropy. - source_logits : torch.Tensor Model predictions for source domain. - target_logits : torch.Tensor Model predictions for target domain.

Notes

Combines multiple loss terms:

  • Source classification loss
  • Domain adversarial loss
  • Target entropy minimization loss
init_model(**kwargs)

Initialize the UDAGCN model.

Parameters:
  • **kwargs

    Other parameters for the UDAGCNBase model.

Returns:
  • UDAGCNBase

    Initialized UDAGCN model on the specified device.

predict(data, source=False)

Make predictions on given data.

Parameters:
  • data (Data) –

    Input graph data.

  • source (bool, default: False ) –

    Whether the input is from source domain. Default: False.

Returns:
  • tuple

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

Notes

Handles both node-level and graph-level predictions using appropriate pooling operations.

process_graph(data)

Process the input graph data.

Parameters:
  • data (Data) –

    Input graph data to be processed.

Notes

Placeholder method for graph preprocessing.