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

ValueError: Array contains NaN or infinity. #4

Closed
duanLH opened this issue Aug 17, 2016 · 4 comments
Closed

ValueError: Array contains NaN or infinity. #4

duanLH opened this issue Aug 17, 2016 · 4 comments

Comments

@duanLH
Copy link

duanLH commented Aug 17, 2016

When I run the following codes using the download models.
python2 tools/test_net.py --gpu 0
--gallery_def models/psdb/VGG16/test_gallery.prototxt
--probe_def models/psdb/VGG16/test_probe.prototxt
--net output/psdb_train/VGG16_iter_100000.caffemodel
--cfg experiments/cfgs/train.yml
--imdb psdb_test

It shows that

/usr/lib/python2.7/dist-packages/sklearn/metrics/metrics.py:599: RuntimeWarning: invalid value encountered in true_divide
recall = tps / tps[-1]
Traceback (most recent call last):
File "/home/duan/person_search-master/tools/test_net.py", line 218, in
evaluate(protoc, imdb.image_index, output_dir, args.gallery_size == 0)
File "/home/duan/person_search-master/tools/test_net.py", line 111, in evaluate
ap = average_precision_score(y_true, y_score) * recall_rate
File "/usr/lib/python2.7/dist-packages/sklearn/metrics/metrics.py", line 314, in average_precision_score
return auc(recall, precision)
File "/usr/lib/python2.7/dist-packages/sklearn/metrics/metrics.py", line 172, in auc
x, y = check_arrays(x, y)
File "/usr/lib/python2.7/dist-packages/sklearn/utils/validation.py", line 233, in check_arrays
_assert_all_finite(array)
File "/usr/lib/python2.7/dist-packages/sklearn/utils/validation.py", line 27, in _assert_all_finite
raise ValueError("Array contains NaN or infinity.")
ValueError: Array contains NaN or infinity.

thanks~

@Cysu
Copy link
Collaborator

Cysu commented Aug 17, 2016

It might be helpful to update or reinstall the sklearn package.

pip install -U scikit-learn

My version is scikit-learn==0.17.1. From the source code here, there seems to be no sklearn/metrics/metrics.py.

@duanLH
Copy link
Author

duanLH commented Aug 18, 2016

@Cysu It worked! thanks.

@duanLH duanLH closed this as completed Aug 18, 2016
@blasheroy
Copy link

blasheroy commented Oct 27, 2016

Hi, I also encounter same problem but the problem still exists even I do pip install -U scikit-learn
My scikit-learn version is 0.18
screenshot from 2016-10-27 10 53 28

@Cysu
Copy link
Collaborator

Cysu commented Oct 27, 2016

@blasheroy Could you please check the output of the following commands?

which python
which pip
pip freeze | grep scikit-learn

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

3 participants