Closed mohitiitb closed 4 years ago
random returns a float64 matrix, you should convert it to float32
@mdouze @mohitiitb Hey! I am also getting an error similar to this. What did you change in the code? Because for my case, I already have the output in float32 format. Also, I am running the cluster mode for now at the beginning before the training mode according to the repository (https://github.com/Nanne/pytorch-NetVlad).
===> Loading dataset(s) ===> Building model ===> Calculating descriptors and clusters ====> Extracting Descriptors ====> Clustering.. Traceback (most recent call last): File "main.py", line 496, in get_clusters(whole_train_set) File "main.py", line 279, in get_clusters kmeans.train(dbFeat[...]) File "/home/kau4hi/gpu_anaconda3/lib/python3.6/site-packages/faiss/init.py", line 734, in train clus.train(x, self.index, weights) File "/home/kau4hi/gpu_anaconda3/lib/python3.6/site-packages/faiss/init.py", line 85, in replacement_train self.train_c(n, swig_ptr(x), index) File "/home/kau4hi/gpu_anaconda3/lib/python3.6/site-packages/faiss/swigfaiss_avx2.py", line 1477, in train return _swigfaiss_avx2.Clustering_train(self, n, x, index, x_weights) NotImplementedError: Wrong number or type of arguments for overloaded function 'Clustering_train'. Possible C/C++ prototypes are: faiss::Clustering::train(faiss::Clustering::idx_t,float const ,faiss::Index &,float const ) faiss::Clustering::train(faiss::Clustering::idx_t,float const *,faiss::Index &)
As suggested by @mdouze the data type of variable taken by kmeans.train() function has to kept as float32. Just look through the particular function you are operating on in your file.
The script kmeans.py: `import numpy as np import faiss
x = np.random.rand(4,2)
ncentroids = 2 niter = 20 verbose = True d = x.shape[1] print(d) kmeans = faiss.Kmeans(d, ncentroids, niter=niter, verbose=verbose, spherical=True) kmeans.train(x)`
Error: Traceback (most recent call last): File "kmeans.py", line 21, in
kmeans.train(x)
File "/opt/conda/lib/python3.7/site-packages/faiss/init.py", line 734, in train
clus.train(x, self.index, weights)
File "/opt/conda/lib/python3.7/site-packages/faiss/init.py", line 85, in replacement_train
self.train_c(n, swig_ptr(x), index)
File "/opt/conda/lib/python3.7/site-packages/faiss/swigfaiss.py", line 1094, in train
return _swigfaiss.Clustering_train(self, n, x, index, x_weights)
TypeError: Wrong number or type of arguments for overloaded function 'Clustering_train'.
Possible C/C++ prototypes are:
faiss::Clustering::train(faiss::Clustering::idx_t,float const ,faiss::Index &,float const )
faiss::Clustering::train(faiss::Clustering::idx_t,float const *,faiss::Index &)