Skip to content

Commit

Permalink
fixed to numpy 1.26 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
michelecafagna26 authored May 3, 2024
1 parent 916ec48 commit 22cb87b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compress_fasttext/pq_encoder_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

0 comments on commit 22cb87b

Please sign in to comment.