Struct faiss::CenteringTransform

struct CenteringTransform : public faiss::VectorTransform

Subtract the mean of each component from the vectors.

Public Functions

explicit CenteringTransform(int d = 0)
virtual void train(idx_t n, const float *x) override

train on n vectors.

virtual void apply_noalloc(idx_t n, const float *x, float *xt) const override

subtract the mean

virtual void reverse_transform(idx_t n, const float *xt, float *x) const override

add the mean

virtual void check_identical(const VectorTransform &other) const override
float *apply(idx_t n, const float *x) const

apply the transformation and return the result in an allocated pointer

Parameters:
  • n – number of vectors to transform

  • x – input vectors, size n * d_in

Returns:

output vectors, size n * d_out

Public Members

std::vector<float> mean

Mean, size d_in = d_out.

int d_in
int d_out

! input dimension

bool is_trained

set if the VectorTransform does not require training, or if training is done already