Class: Faiss::ProductQuantizer

Inherits:
Object
  • Object
show all
Defined in:
lib/faiss/product_quantizer.rb

Instance Method Summary collapse

Instance Method Details

#compute_codes(objects) ⇒ Object



8
9
10
11
12
13
# File 'lib/faiss/product_quantizer.rb', line 8

def compute_codes(objects)
  objects = Numo::SFloat.cast(objects) unless objects.is_a?(Numo::SFloat)
  n = objects.shape[0]
  res = _compute_codes(n, objects)
  Numo::UInt8.from_binary(res).reshape(n, m)
end

#decode(objects) ⇒ Object



15
16
17
18
19
20
# File 'lib/faiss/product_quantizer.rb', line 15

def decode(objects)
  objects = Numo::UInt8.cast(objects) unless objects.is_a?(Numo::UInt8)
  n = objects.shape[0]
  res = _decode(n, objects)
  Numo::SFloat.from_binary(res).reshape(n, d)
end

#train(objects) ⇒ Object



3
4
5
6
# File 'lib/faiss/product_quantizer.rb', line 3

def train(objects)
  objects = Numo::SFloat.cast(objects) unless objects.is_a?(Numo::SFloat)
  _train(objects.shape[0], objects)
end