-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
TypeError: 'numpy.float64' object cannot be interpreted as an index #481
Comments
Same problem! An int type is expected. |
Yes, the ability to use floating point indices was deprecated for a bit; It was finally removed in 1.12. You can also fix the problem by modifying lib/roi_data_layer/minibatch.py On line 26, there's a call to np.round I believe there are only 3 other places where floats are being used to index, so you'd have to add lib/datasets/ds_utils.py line 12 : hashes = np.round(boxes * scale).dot(v) I guess if you're really bored you can sniff out any remaining problematic float indexing attempts, or if you're not then maybe yes, you should install numpy 1.11.0 as suggested above! |
There seems to be a similar error caused by line 173 in lib/roi_data_layer/minibatch.py. |
Thanks that fixed it! |
@PentaHiggs Thanks a lot!! your solution works well, my questions were fixed. |
Iam having the same error.i tried to resolve error with numpy version as : |
@PentaHiggs & @DavidSPumpkins Thanks!! It worked i think .The training is not complete though.Thanks. |
Hey @sulth |
@tzrtzr000 I would try upgrading to numpy 1.13 and solving the "index not an int" problem, as described earlier in this thread. |
@tzrtzr000 @sulth Have you solved the problem? |
yes .I followed @PentaHiggs & @DavidSPumpkins .It really helped . |
@yanxp Yes. I adopted @PentaHiggs' solution : ) |
@tzrtzr000 I have the same problem (ImportError: numpy.core.multiarray failed to import) after downgrading to 1.11. How did you figure it out? Thanks! |
@Xinying666 try solution provided by @PentaHiggs above |
@tzrtzr000 I tried,but no work for me |
If you have the same error, you'd better check this sentence: fg_inds = npr.choice( |
I cannot locate roi_data_layer/minibatch.py under Lib. Is there any other solutions that I can try for this problem? I am using python from anaconda 3.6.
|
Compiled changes necessary for proper integer slicing.
|
Thanks @PentaHiggs! |
i tried the suggested solutions of downgrading numpy and adding .astype(np.int). But they cannot solve my same error ''numpy.float64' object cannot be interpreted as an integer'. Anyone encounters the same case with me? |
A have the same error
|
@bosonbeard You are trying to use a float, namely a numpy.float, as an index. But that index needs to an int. So you need to cast the num from a float to an int. |
Hi all, 'numpy.float64' object cannot be interpreted as an index from the following code: FluxDispMatSmall = np.zeros([5,5]) I'm using anaconda 1.9.12 on a Mac. with Python 2.7 thanks so much. |
I don't think the issue would be fixed by changing the numpy version. It seems like a common data type issue that can be easily fixed with type casting. Python is picky about data types and will complain if you use floats to indicate an array index. The array expects an integer so (index=5.0; array[index]) wouldn't work but (index=5; array[index]) would. To fix this error with type casting, just wrap the variable with int() to cast it as an integer. (i.e. index=5.0; array[int(index)]) and (index=int(5.0); array[index]) would both work. The second version would permanently change the index variable type to int. |
Snsie THANK YOU !! .. I got it to work with your help. :) Have a great day. |
Hey, I hope this will work but i am not able to locate minibatch.py file in my project, can anybody help? |
I am hitting an error when following the tutorial linked below, which uses the INRIA Person dataset as an example.
https://github.com/deboc/py-faster-rcnn/tree/master/help
Everything seems to be working, but after two hours I keep hitting the following error at Process 3:
Solving...
Process Process-3:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "./tools/train_faster_rcnn_alt_opt.py", line 236, in train_fast_rcnn
max_iters=max_iters
File "/home/scott/code/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 185, in train_net
model_paths = sw.train_model(max_iters)
File "/home/scott/code/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 112, in train_model
self.solver.step(1)
File "/home/scott/code/py-faster-rcnn/tools/../lib/roi_data_layer/layer.py", line 155, in forward
blobs = self._get_next_minibatch()
File "/home/scott/code/py-faster-rcnn/tools/../lib/roi_data_layer/layer.py", line 68, in _get_next_minibatch
return get_minibatch(minibatch_db, self._num_classes)
File "/home/scott/code/py-faster-rcnn/tools/../lib/roi_data_layer/minibatch.py", line 64, in get_minibatch
num_classes)
File "/home/scott/code/py-faster-rcnn/tools/../lib/roi_data_layer/minibatch.py", line 110, in _sample_rois
fg_inds, size=fg_rois_per_this_image, replace=False
File "mtrand.pyx", line 1176, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:18822)
TypeError: 'numpy.float64' object cannot be interpreted as an index
Does anyone know what might be causing this problem?
The text was updated successfully, but these errors were encountered: