torch_geometric.nn.pool.ApproxL2KNNIndex
- class ApproxL2KNNIndex(num_cells: int, num_cells_to_visit: int, bits_per_vector: int, emb: Optional[Tensor] = None, reserve: Optional[int] = None)[source]
Bases:
KNNIndex执行快速的近似\(k\)-最近邻搜索 (\(k\)-NN),基于\(L_2\)度量,通过
faiss库。 需要调整超参数以权衡速度与准确性。- Parameters:
num_cells (int) – The number of cells.
num_cells_to_visit (int) – The number of cells that are visited to perform to search.
bits_per_vector (int) – The number of bits per sub-vector.
emb (torch.Tensor, optional) – The data points to add. (default:
None)reserve (int, optional) – The number of elements to reserve memory for before re-allocating (GPU only). (default:
None)