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}") | |