PlanetAlign.algorithms.WAlign

class WAlign(setup: int = 4, prior_rate: float = 0.02, alpha: float = 0.01, out_dim: int = 512, lr: float = 0.001, lr_wd: float = 0.01, lr_recon: float = 0.01, transform: bool = True, dtype: dtype = torch.float32)[source]

Bases: BaseModel

Embedding-based method WAlign for unsupervised pairwise attributed network alignment. WAlign is proposed by the paper “Unsupervised Graph Alignment with Wasserstein Distance Discriminator.” in KDD 2021.

Parameters:
  • setup (int, optional) – The setup of the model. Choose from [1, 2, 3, 4]. Default is 4.

  • prior_rate (float, optional) – The rate of prior knowledge. Default is 0.02.

  • alpha (float, optional) – The hyperparameter balancing the Wasserstein distance loss and the reconstruction loss. Default is 1e-2.

  • out_dim (int, optional) – The dimension of the output embeddings. Default is 512.

  • lr (float, optional) – The learning rate for the model. Default is 1e-3.

  • lr_wd (float, optional) – The learning rate for the Wasserstein discriminator. Default is 1e-2.

  • lr_recon (float, optional) – The learning rate for the reconstruction model. Default is 1e-2.

  • transform (bool, optional) – Whether to use the transformation layer. Default is True.

  • 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, total_epochs: int = 20, use_attr: bool = True, save_log: bool = True, verbose: bool = True)[source]
Parameters:
  • dataset (Dataset) – The dataset containing the graphs to be aligned and the training/test data.

  • gid1 (int) – The index of the first graph in the dataset to be aligned.

  • gid2 (int) – The index of the second graph in the dataset to be aligned.

  • use_attr (bool, optional) – Whether to use node and edge attributes for alignment. Default is True.

  • total_epochs (int, optional) – The total number of training epochs. Default is 20.

  • save_log (bool, optional) – Whether to save the training log. Default is True.

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