Skip to content

Commit

Permalink
fix: small bug in _updated_centroids() in kmeans.py, wrong initializa…
Browse files Browse the repository at this point in the history
…tion of zero_counts (#1885)

Spotted a one-line bug in _updated_centroids()

Co-authored-by: Lei Xu <[email protected]>
  • Loading branch information
lillianye and eddyxu authored Jan 31, 2024
1 parent 5807cde commit 1a67a17
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/python/lance/torch/kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _updated_centroids(
self, centroids: torch.Tensor, counts: torch.Tensor
) -> torch.Tensor:
centroids = centroids / counts[:, None]
zero_counts = centroids == 0
zero_counts = counts == 0
for idx in zero_counts.nonzero(as_tuple=False):
# split the largest cluster and remove empty cluster
max_idx = torch.argmax(counts).item()
Expand Down

0 comments on commit 1a67a17

Please sign in to comment.