File size: 331 Bytes
328f79a
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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}")