结构体 faiss::RandomRotationMatrix
-
struct RandomRotationMatrix : public faiss::LinearTransform
随机旋转一组向量。
公共函数
-
inline RandomRotationMatrix(int d_in, int d_out)
同时支持 d_in > d_out 和 d_out < d_in
-
void init(int seed)
在使用转换之前必须调用
-
virtual void train(idx_t n, const float *x) override
在一组有代表性的向量上执行训练。默认情况下不执行任何操作。
- 参数:
n – 训练向量的数量
x – 训练向量,大小为 n * d
-
inline RandomRotationMatrix()
-
virtual void apply_noalloc(idx_t n, const float *x, float *xt) const override
与 apply 相同,但结果是预先分配的
-
void transform_transpose(idx_t n, const float *y, float *x) const
计算 x = A^T * (x - b),如果 A 具有正交线,则为反向变换
-
virtual void reverse_transform(idx_t n, const float *xt, float *x) const override
仅在 is_orthonormal 为真时有效
-
void set_is_orthonormal()
计算 A^T * A 以设置 is_orthonormal 标志
-
void print_if_verbose(const char *name, const std::vector<double> &mat, int n, int d) const
-
virtual void check_identical(const VectorTransform &other) const override
-
float *apply(idx_t n, const float *x) const
应用变换,并在分配的指针中返回结果
- 参数:
n – 要变换的向量数
x – 输入向量,大小为 n * d_in
- 返回:
输出向量,大小为 n * d_out
公共成员
-
bool have_bias
-
bool is_orthonormal
! 是否使用偏差项
检查矩阵A是否为正交矩阵(启用 reverse_transform)
-
std::vector<float> A
变换矩阵,大小为 d_out * d_in。
-
std::vector<float> b
偏差向量,大小为 d_out
-
bool verbose
-
int d_in
-
int d_out
! 输入维度
-
bool is_trained
设置 VectorTransform 是否不需要训练,或者是否已经完成训练
-
inline RandomRotationMatrix(int d_in, int d_out)