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

Bases: BaseGDA

Adversarial Deep Network Embedding for Cross-network Node Classification (AAAI-20).

Parameters:
  • in_dim (int) –

    Input feature dimension.

  • hid_dim (int) –

    Hidden dimension of model.

  • num_classes (int) –

    Total number of classes.

  • dropout (float, default: 0.0 ) –

    Dropout rate. Default: 0..

  • weight_decay (float, default: 0.0 ) –

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

  • n_emb (int, default: 128 ) –

    Adversarial learning module hidden dimension. Default: 128.

  • pair_weight (float, default: 0.1 ) –

    Trade-off hyper-parameter for pairwise constraint. Default: 0.1.

  • step (int, default: 3 ) –

    Propagation steps in PPMI matrix. Default: 3.

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

    Maximum number of training epoch. Default: 100.

  • device (str, default: 'cuda:0' ) –

    GPU or CPU. Default: cuda:0.

  • batch_size (int, default: 100 ) –

    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.

agg_tran_prob_mat(g, step)

Compute aggregated K-step transition probability matrix.

Parameters:
  • g (csc_matrix) –

    Graph adjacency matrix.

  • step (int) –

    Number of transition steps.

Returns:
  • ndarray

    Aggregated transition probability matrix.

Notes

Aggregates transition probabilities up to K steps for capturing higher-order proximity.

batch_generator(data, batch_size, shuffle=True)

Generate mini-batches from data.

Parameters:
  • data (list) –

    List of arrays to be batched.

  • batch_size (int) –

    Size of each batch.

  • shuffle (bool, default: True ) –

    Whether to shuffle data. Default: True.

Yields:
  • tuple

    Contains: - batch_data : list List of arrays for current batch. - shuffle_index : np.ndarray Shuffle indices for current batch.

batch_ppmi(batch_size, shuffle_index_s, shuffle_index_t, ppmi_s, ppmi_t)

Extract PPMI matrices for mini-batch nodes.

Parameters:
  • batch_size (int) –

    Size of mini-batch.

  • shuffle_index_s (ndarray) –

    Shuffled indices for source domain.

  • shuffle_index_t (ndarray) –

    Shuffled indices for target domain.

  • ppmi_s (ndarray) –

    PPMI matrix of source domain.

  • ppmi_t (ndarray) –

    PPMI matrix of target domain.

Returns:
  • tuple

    Contains: - a_s : np.ndarray Normalized PPMI matrix for source batch. - a_t : np.ndarray Normalized PPMI matrix for target batch.

compute_ppmi(a)

Compute Positive Pointwise Mutual Information (PPMI) matrix.

Parameters:
  • a (ndarray) –

    Aggregated transition probability matrix.

Returns:
  • ndarray

    PPMI matrix.

Notes

PPMI captures the statistical significance of node co-occurrences in random walks.

fit(source_data, target_data)

Train the ACDNE model.

Parameters:
  • source_data (Data) –

    Source domain graph data.

  • target_data (Data) –

    Target domain graph data.

Notes

Training process includes:

  • Processing graph data to compute PPMI matrices
  • Concatenating node features with neighbor features
  • Training with mini-batch strategy
  • Optimizing classification, domain adaptation, and network proximity losses
forward_model(**kwargs)

Forward pass of the model.

Parameters:
  • **kwargs

    Placeholder for compatibility.

init_model(**kwargs)

Initialize the ACDNE model.

Parameters:
  • **kwargs

    Other parameters for the ACDNEBase model.

Returns:
  • ACDNEBase

    Initialized ACDNE model on the specified device.

my_scale_sim_mat(w)

Compute L1 row normalization of a matrix.

Parameters:
  • w (ndarray or csc_matrix) –

    Input matrix to be normalized.

Returns:
  • ndarray or csc_matrix

    Row-normalized matrix.

predict(data, train=False)

Make predictions on given data.

Parameters:
  • data (Data) –

    Input graph data.

  • train (bool, default: False ) –

    Whether in training mode. Default: False.

Returns:
  • tuple

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

process_graph(data)

Process the input graph data.

Parameters:
  • data (Data) –

    Input graph data.

Returns:
  • tuple

    Contains: - A_ppmi : np.ndarray PPMI matrix of the graph. - X_nei : np.ndarray Aggregated neighbor features.

Notes

Computes PPMI matrix and aggregated neighbor features for network embedding.

shuffle_aligned_list(data)

Shuffle multiple aligned lists together.

Parameters:
  • data (list) –

    List of arrays to be shuffled in the same order.

Returns:
  • tuple

    Contains: - shuffle_index : np.ndarray Generated shuffle indices. - shuffled_data : list List of shuffled arrays.