How to use a CSR matrix to get similarity #3563
Vikram12301
started this conversation in
General
Replies: 1 comment
-
Faiss indexes dense vectors. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
import faiss
from scipy.sparse import csr_matrix
rows = [0, 1, 1, 2]
cols = [0, 1, 2, 1]
vals = [1, 2, 3, 4]
csr_mat = csr_matrix((vals, (rows, cols)), shape=(3, 3))
index = faiss.IndexFlatIP(csr_mat.shape[1])
index.add(csr_mat.indptr, csr_mat.indices, csr_mat.data)
I got this error on running the above code
TypeError: replacement_add() takes 2 positional arguments but 4 were given
How to get the right similarity?
Beta Was this translation helpful? Give feedback.
All reactions