结构体 faiss::NormalizationTransform

struct NormalizationTransform : public faiss::VectorTransform

逐向量归一化

公共函数

explicit NormalizationTransform(int d, float norm = 2.0)
NormalizationTransform()
virtual void apply_noalloc(idx_t n, const float *x, float *xt) const override

应用变换并在提供的矩阵中返回结果

参数:
  • n – 要变换的向量数

  • x – 输入向量,大小 n * d_in

  • xt – 输出向量,大小 n * d_out

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

由于 norm 不可逆,因此为恒等变换。

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

在一组代表性向量上执行训练。默认情况下不执行任何操作。

参数:
  • n – 训练向量的个数

  • x – 训练向量,大小 n * d

float *apply(idx_t n, const float *x) const

应用变换并在分配的指针中返回结果

参数:
  • n – 要变换的向量数

  • x – 输入向量,大小 n * d_in

返回值:

输出向量,大小 n * d_out

公共成员

float norm
int d_in
int d_out

! 输入维度

bool is_trained

如果 VectorTransform 不需要训练,或者已经完成训练,则设置此标志