Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 12, 2024
1 parent 763b255 commit 4fbf7e4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions heat/cluster/batchparallelclustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def _initialize_plus_plus(X, n_clusters, p, random_state=None, max_samples=2**24
torch.manual_seed(random_state)
if X.shape[0] > max_samples: # torch's multinomial is limited to 2^24 categories
idxs_subsampling = torch.randint(0, X.shape[0], (max_samples,))
X = X[idxs_subsampling]
# actual K-Means++
X = X[idxs_subsampling]
# actual K-Means++
idxs = torch.zeros(n_clusters, dtype=torch.long, device=X.device)
idxs[0] = torch.randint(0, X.shape[0], (1,))
for i in range(1, n_clusters):
Expand All @@ -40,6 +40,7 @@ def _initialize_plus_plus(X, n_clusters, p, random_state=None, max_samples=2**24
idxs[i] = torch.multinomial(dist, 1)
return X[idxs]


def _kmex(X, p, n_clusters, init, max_iter, tol, random_state=None):
"""
Auxiliary function: single-process k-means and k-medians in pytorch
Expand Down

0 comments on commit 4fbf7e4

Please sign in to comment.