KBL(in_dim, hid_dim, num_classes, k_cross=50, k_within=10, num_layers=2, dropout=0.0, act=F.relu, weight_decay=0.005, lr=0.001, epoch=200, device='cuda:0', batch_size=0, num_neigh=-1, verbose=2, **kwargs)

Bases: BaseGDA

Bridged-GNN: Knowledge Bridge Learning for Effective Knowledge Transfer (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: 2 ) –

    Total number of layers in model. Default: 2.

  • dropout (float, default: 0.0 ) –

    Dropout rate. Default: 0..

  • weight_decay (float, default: 0.005 ) –

    Weight decay (L2 penalty). Default: 0.005.

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

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

  • k_cross (int, default: 50 ) –

    Number of edges for cross domains. Default: 50.

  • k_within (int, default: 10 ) –

    Number of edges for within domains. Default: 10.

  • lr (float, default: 0.001 ) –

    Learning rate. Default: 0.001.

  • 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 KBL 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:

  • Stores source and target data for bridge construction
  • Creates data loaders (full batch only)

Bridge construction:

  • Builds knowledge bridge between domains
  • Creates unified graph with cross-domain connections
  • Converts to undirected graph structure

Training loop:

  • Processes merged graph with knowledge bridges
  • Updates model parameters using central nodes
  • Tracks and logs:

    • Classification loss
    • Training accuracy
    • Computation time
Important

Only supports full-batch training (batch_size must be 0)

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.

Notes

Placeholder method as the main forward logic is handled in the fit method through bridged graph processing.

init_model(**kwargs)

Initialize the Knowledge Bridge Learning (KBL) model.

Parameters:
  • **kwargs

    Additional parameters for the KBLBase model.

Returns:
  • KBLBase

    Initialized model on the specified device.

Notes

Configures the base model with specific parameters:

  • Bridge construction parameters (k_cross, k_within)
  • Model architecture (hidden dimensions, layers)
  • Training settings (learning rate, weight decay)
  • Normalization options
predict(data)

Make predictions on given data.

Parameters:
  • data (Data) –

    Input graph data.

Returns:
  • tuple

    Contains: - logits : torch.Tensor Model predictions for the input data. - labels : torch.Tensor True labels.

Notes

Uses the stored bridged graph for inference, extracting predictions for the target nodes.

process_graph(data)

Process the input graph data.

Parameters:
  • data (Data) –

    Input graph data to be processed.

Notes

Placeholder method for graph preprocessing.