From 22cb87b74f3e86016f9d7fab1ecaf868b9b0765c Mon Sep 17 00:00:00 2001 From: michelecafagna26 Date: Fri, 3 May 2024 08:21:23 +0200 Subject: [PATCH] fixed to numpy 1.26 (#24) --- compress_fasttext/pq_encoder_light.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compress_fasttext/pq_encoder_light.py b/compress_fasttext/pq_encoder_light.py index f34a1fd..d2d579f 100644 --- a/compress_fasttext/pq_encoder_light.py +++ b/compress_fasttext/pq_encoder_light.py @@ -70,9 +70,9 @@ def fit(self, x_train): self.Ds = int(D / self.M) assert self.trained_encoder is None, "fit must be called only once" - codewords = numpy.zeros((self.M, self.Ks, self.Ds), dtype=numpy.float) + codewords = numpy.zeros((self.M, self.Ks, self.Ds), dtype=numpy.float32) for m in range(self.M): - x_train_sub = x_train[:, m * self.Ds: (m + 1) * self.Ds].astype(numpy.float) + x_train_sub = x_train[:, m * self.Ds: (m + 1) * self.Ds].astype(numpy.float32) codewords[m], _ = kmeans2(x_train_sub, self.Ks, iter=self.iteration, minit='points') self.trained_encoder = TrainedPQEncoder(codewords, self.code_dtype) @@ -117,7 +117,7 @@ def decode_multi(self, codes): assert M == self.M assert codes.dtype == self.code_dtype - decoded = numpy.empty((N, self.Ds * self.M), dtype=numpy.float) + decoded = numpy.empty((N, self.Ds * self.M), dtype=numpy.float32) for m in range(self.M): decoded[:, m * self.Ds: (m + 1) * self.Ds] = self.codewords[m][codes[:, m], :] return decoded