GNN(in_dim, hid_dim, num_classes, num_layers=2, dropout=0.0, gnn='gcn', act=F.relu, weight_decay=0.0001, lr=0.05, epoch=100, device='cuda:0', batch_size=0, num_neigh=-1, verbose=2, **kwargs)

Bases: BaseGDA

General GNN model without adaptation.

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: 2 ) –

    Total number of layers in model. Default: 2.

  • dropout (float, default: 0.0 ) –

    Dropout rate. Default: 0..

  • gnn (string, default: 'gcn' ) –

    GNN backbone. Default: gcn.

  • weight_decay (float, default: 0.0001 ) –

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

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

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

  • lr (float, default: 0.05 ) –

    Learning rate. Default: 0.001.

  • epoch (int, default: 100 ) –

    Maximum number of training epoch. Default: 100.

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

  • **kwargs

    Other parameters for the model.

fit(source_data, target_data)

Train the GNN model.

Parameters:
  • source_data (Data) –

    Source domain graph data.

  • target_data (Data) –

    Target domain graph data.

Notes

The training process includes: - Creating data loaders for both domains - Initializing the GNN model and optimizer - Training for specified number of epochs - Logging training progress (loss and micro-F1 score)

forward_model(source_data, target_data)

Forward pass of the model.

Parameters:
  • source_data (Data) –

    Source domain graph data.

  • target_data (Data) –

    Target domain graph data.

Returns:
  • tuple

    Contains (loss, source_logits, target_logits): - loss : torch.Tensor Cross entropy loss on source domain - source_logits : torch.Tensor Model predictions for source domain - target_logits : torch.Tensor Model predictions for target domain

init_model(**kwargs)

Initialize the GNN model.

Parameters:
  • **kwargs

    Other parameters for the GNNBase model.

Returns:
  • GNNBase

    Initialized GNN model on the specified device.

predict(data)

Make predictions using the trained model.

Parameters:
  • data (Data) –

    Input graph data.

Returns:
  • tuple

    Contains (logits, labels): - logits : torch.Tensor Model predictions - labels : torch.Tensor True labels from the data

process_graph(data)

Process the input graph data.

Parameters:
  • data (Data) –

    Input graph data to be processed.

Notes

This is a placeholder method that should be implemented by subclasses if graph preprocessing is needed.