PlanetAlign.algorithms.NetTrans

class NetTrans(hid_dim: int = 128, depth: int = 2, pooling_ratio: float = 0.2, attr_coeff: float = 1.0, adj_coeff: float = 1.0, rank_coeff: float = 1.0, margin: float = 1.0, neg_size: int = 20, batch_size: int = 300, lr: float = 0.001, temperature: float = 1.0, min_temperature: float = 0.1, anneal_rate: float = 2e-05, dtype: dtype = torch.float32)[source]

Bases: BaseModel

Embedding-based method NetTrans for pairwise network alignment via network transformation. NetTrans is proposed by the paper “NetTrans: Neural Cross-Network Transformation.” in KDD 2020.

Parameters:
  • hid_dim (int, optional) – Hidden dimension of the model. Default is 128.

  • depth (int, optional) – Network depth of the model. Default is 2.

  • pooling_ratio (float, optional) – Pooling ratio of the model. Default is 0.2.

  • attr_coeff (float, optional) – Coefficient for the attribute loss. Default is 1.0.

  • adj_coeff (float, optional) – Coefficient for the structural loss. Default is 1.0.

  • rank_coeff (float, optional) – Coefficient for the ranking loss. Default is 1.0.

  • margin (float, optional) – Margin for the ranking loss. Default is 1.0.

  • neg_size (int, optional) – Number of negative samples per anchor link. Default is 20.

  • batch_size (int, optional) – Batch size for training. Default is 300.

  • lr (float, optional) – Learning rate for the optimizer. Default is 0.001.

  • temperature (float, optional) – Initial temperature for the model. Default is 1.0.

  • min_temperature (float, optional) – Minimum temperature for the model. Default is 0.1.

  • anneal_rate (float, optional) – Anneal rate for the temperature. Default is 2e-5.

  • dtype (torch.dtype, optional) – Data type of the tensors, choose from torch.float32 or torch.float64. Default is torch.float32.

test(dataset: Dataset, gids: List[int] | Tuple[int, ...], metrics: tuple[str] | list[str] = None)
Parameters:
  • dataset (Dataset) – The dataset containing the graphs to be aligned and the training/test data.

  • gids (list[int] or tuple[int, ...]) – The indices of the graphs in the dataset to be aligned.

  • metrics (tuple[str] or list[str], optional) – The metrics to be computed after alignment. Default is None, which computes Hits@K (K=1, 10, 30, 50) and MRR metrics.

train(dataset: Dataset, gid1: int, gid2: int, use_attr: bool = True, total_epochs: int = 50, save_log: bool = True, verbose: bool = True)[source]
Parameters:
  • dataset (Dataset) – The dataset containing graphs to be aligned and the training/test data.

  • gid1 (int) – The graph id of the first graph to be aligned.

  • gid2 (int) – The graph id of the second graph to be aligned.

  • use_attr (bool, optional) – Flag for using attributes. Default is True.

  • total_epochs (int, optional) – Maximum number of training epochs. Default is 50.

  • save_log (bool, optional) – Flag for saving the training log. Default is True.

  • verbose (bool, optional) – Whether to print the progress during training. Default is True.