Closed ReagTea closed 2 months ago
This may be due to the transformation into a matrix multiplication, see https://github.com/facebookresearch/faiss/wiki/Implementation-notes#matrix-multiplication-to-do-many-l2-distance-computations
This issue is stale because it has been open for 7 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.
Summary
Trying to compute distance matrix on two identical vectors with
faiss.pairwise_distances
and compare it to scipycKDTree.sparse_distance_matrix
frequently fails because it seems that Faiss returns less exactly 0 distance values in the matrix. In consequence, it can happen that the number of non zero values differ between both matrices.The results of
cKDTree.sparse_distance_matrix
can always be matched exactly byscipy.spatial.distance.cdist
, less frequently so bysklearn.metrics.pairwise_distances
.I can imagine that it could be due to some numerical precision errors, but I'd like to understand algorithmically how Scipy can return the exact expected number of 0 distance values when computing a distance matrix on two same vectors.
Thank you.
Platform
OS: Linux Debian amd64
Faiss version: 1.7.1 MKL / llvm Openmp
Installed from: Conda channel conda-forge
Faiss compilation options: MKL, AVX2
Running on:
Interface:
Reproduction instructions