当前位置: 代码迷 >> 综合 >> faiss错误原因分析与解决 --- assert ids.shape == (n, ), AssertionError: not same nb of vectors as ids
  详细解决方案

faiss错误原因分析与解决 --- assert ids.shape == (n, ), AssertionError: not same nb of vectors as ids

热度:110   发布时间:2023-10-26 00:24:19.0

0.环境

ubuntu16.04
python3.6
faiss-gpu==1.6.3

1.问题

使用index.add_with_ids过程中出现错误:

index.add_with_ids(nb, ids)

 assert ids.shape == (n, ), AssertionError: not same nb of vectors as ids

2.原因定位分析

这里说维度不一样,那将nb,ids的维度分别打印输出一下:

print(nb.shape)
print(ids.shape)
index.add_with_ids(nb, ids)

根据上面的情况,去查程序,怎么导致nb与ids维度不一样,定位以后就可以解决了。

  相关解决方案