src.spectral_clustering.kmeans(X: torch.Tensor, num_clusters: int, init_x: Union[torch.Tensor, str] = 'plus', distance: str = 'euclidean', tol: float = 0.0001, device=device(type='cpu')) Tuple[torch.Tensor, torch.Tensor][source]

Perform kmeans on given data matrix \(\mathbf X\).

  • X\((n\times d)\) input data matrix. \(n\): number of samples. \(d\): feature dimension

  • num_clusters – (int) number of clusters

  • init_x – how to initiate x (provide a initial state of x or define a init method) [default: ‘plus’]

  • distance – distance [options: ‘euclidean’, ‘cosine’] [default: ‘euclidean’]

  • tol – convergence threshold [default: 0.0001]

  • device – computing device [default: cpu]


cluster ids, cluster centers