From 11b57d4af8d81dfa8f98ba795787feb613604b43 Mon Sep 17 00:00:00 2001 From: clark-hive Date: Fri, 9 Sep 2022 02:36:20 +0000 Subject: [PATCH] working around issue in kmc2 --- python/bolt/bolt_api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/bolt/bolt_api.py b/python/bolt/bolt_api.py index 291119c5..5bf1d898 100644 --- a/python/bolt/bolt_api.py +++ b/python/bolt/bolt_api.py @@ -137,6 +137,9 @@ def _learn_centroids(X, ncentroids, ncodebooks): start_col = i * subvect_len end_col = start_col + subvect_len X_in = X[:, start_col:end_col] + if np.unique(X_in).size == 1 and X_in.size > 1: + #kmc2 has a bug if all rows of matrix are duplicates + X_in[0,0] += 0.001 centroids, labels = kmeans(X_in, ncentroids) ret[:, i, :] = centroids