anns / sift1m /loading.py
gfhe
INIT:anns
328f79a
raw
history blame
No virus
331 Bytes
import numpy as np
def fvecs_read(fname):
data = np.fromfile(fname, dtype=np.float32)
dim = data[0].view(np.int32)
data = data.reshape(-1, dim + 1)
data = np.ascontiguousarray(data[:, 1:])
ndata, dim = data.shape
return data, ndata, dim
# f = 'sift_base.fvecs'
# sift = fvecs_read(f)
# print(f"{sift.shape}")