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

Bases: ABC

Abstract Class for Graph Domain Adaptation.

Parameters:
  • in_dim

    Input feature dimension.

  • hid_dim ( int) –

    Hidden dimension of model.

  • num_classes

    Total number of classes.

  • num_layers (int, default: 2 ) –

    Total number of layers in model.

  • dropout (float, default: 0.0 ) –

    Dropout rate. Default: 0..

  • weight_decay (float, default: 0.0 ) –

    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.004 ) –

    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(data, **kwargs)

Training the graph neural network.

Parameters:
  • data (Data) –

    The input graph.

forward_model(data, **kwargs) abstractmethod

Forward pass of the graph neural network.

Parameters:
  • data (Data) –

    The input graph.

Returns:
  • loss( Tensor ) –

    The loss of the current batch.

init_model(**kwargs) abstractmethod

Initialize the graph neural network.

Returns:
  • model( Module ) –

    The initialized graph neural network.

predict(data, **kwargs)

Prediction for testing graph using the fitted graph domain adaptation model. Return predicted labels and probabilities by default.

Parameters:
  • data (Data) –

    The testing graph.

Returns:
  • pred( Tensor ) –

    The predicted labels of shape :math:N.

  • prob( Tensor ) –

    The output probabilities of shape :math:N.

process_graph(data, **kwargs) abstractmethod

Data preprocessing for the input graph.

Parameters:
  • data (Data) –

    The input graph.