Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the problem of caffe_traininglayers.py #33

Closed
crazyzsy opened this issue Jun 12, 2017 · 7 comments
Closed

the problem of caffe_traininglayers.py #33

crazyzsy opened this issue Jun 12, 2017 · 7 comments

Comments

@crazyzsy
Copy link

Hi, we take our own color image data set to train the model.but we encounter a question,which is your caffe_traininglayers.py. When running ./train/train_model.sh, I got the following error:TypeError: 'float' object cannot be interpreted as an index .As follows:
I0612 09:26:00.048768 1935 caffe.cpp:221] Starting Optimization
I0612 09:26:00.048841 1935 solver.cpp:279] Solving LtoAB
I0612 09:26:00.048853 1935 solver.cpp:280] Learning Rate Policy: step
Traceback (most recent call last):
File "/home/joy/colorization-master/resources/caffe_traininglayers.py", line 72, in forward
top[0].data[...] = self.nnenc.encode_points_mtx_nd(bottom[0].data[...],axis=1)
File "/home/joy/colorization-master/resources/caffe_traininglayers.py", line 329, in encode_points_mtx_nd
(dists,inds) = self.nbrs.kneighbors(pts_flt)
File "/home/dpa/anaconda2/lib/python2.7/site-packages/sklearn/neighbors/base.py", line 399, in kneighbors
for s in gen_even_slices(X.shape[0], n_jobs)
File "/home/dpa/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 800, in call
while self.dispatch_one_batch(iterator):
File "/home/dpa/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 658, in dispatch_one_batch
self._dispatch(tasks)
File "/home/dpa/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 566, in _dispatch
job = ImmediateComputeBatch(batch)
File "/home/dpa/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 180, in init
self.results = batch()
File "/home/dpa/anaconda2/lib/python2.7/site-packages/sklearn/externals/joblib/parallel.py", line 72, in call
return [func(*args, **kwargs) for func, args, kwargs in self.items]
File "sklearn/neighbors/binary_tree.pxi", line 1310, in sklearn.neighbors.ball_tree.BinaryTree.query (sklearn/neighbors/ball_tree.c:10592)
File "sklearn/neighbors/binary_tree.pxi", line 588, in sklearn.neighbors.ball_tree.NeighborsHeap.init (sklearn/neighbors/ball_tree.c:4931)
TypeError: 'float' object cannot be interpreted as an index
Can anyone help me about this issue?
Thanks appreciately!

@crazyzsy
Copy link
Author

I solved.

@hardik2396
Copy link

@crazyzsy I have got the same error. can you post the solution of it?

@arda-min
Copy link

I changed line 313 to explicitly pick the int member and not the fp parameter:
self.nbrs = nn.NearestNeighbors(n_neighbors= self.NN, algorithm='ball_tree').fit(self.cc)

@hardik2396
Copy link

I still couldn't find the error. Can you please post the exact changes?

@sidgan
Copy link

sidgan commented Aug 23, 2017

@crazyzsy @TerisGH Could you please post your solutions.

@arda-min
Copy link

arda-min commented Aug 24, 2017

In newer versions sklearn.neighbors.NearestNeighbors needs to be initialized with an integer,
so in resources/caffe_traininglayers.py I changed the line creating the NN object from
self.nbrs = nn.NearestNeighbors(n_neighbors=NN, algorithm='ball_tree').fit(self.cc)
to pick self.NN which is an int and can be used as index:
self.nbrs = nn.NearestNeighbors(n_neighbors=self.NN, algorithm='ball_tree').fit(self.cc)

@richzhang
Copy link
Owner

Thanks, I made the corresponding change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants