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

QueryByCommittee 'kl_divergence' method error #174

Open
tsiakmaki opened this issue Feb 28, 2020 · 1 comment
Open

QueryByCommittee 'kl_divergence' method error #174

tsiakmaki opened this issue Feb 28, 2020 · 1 comment

Comments

@tsiakmaki
Copy link

tsiakmaki commented Feb 28, 2020

Hi.
thank you for your contribution.
When testing the QueryByCommittee and the 'kl_divergence' method, i get the above error:

mytest.py", line 90, in run
    ask_id = qs.make_query()
  File ".../python3.7/site-packages/libact/query_strategies/query_by_committee.py", line 207, in make_query
    np.where(np.isclose(avg_kl, np.max(avg_kl)))[0])
  File "mtrand.pyx", line 902, in numpy.random.mtrand.RandomState.choice
ValueError: 'a' cannot be empty unless no samples are taken

In my case, it seems that avg_kl
https://github.com/ntucllab/libact/blob/master/libact/query_strategies/query_by_committee.py#L205
contains NaN, and as such the max is nan.
But also there are cases where all values are Nan, and i get the

ValueError: zero-size array to reduction operation maximum which has no identity

Just a notice, in case it makes sense to anyone else.

@yangarbiter
Copy link
Collaborator

yangarbiter commented Feb 28, 2020

I think the nan should come from here, if predict_proba from the classifier outputs a 0 probability, the kldivergence will have a nan value

kl = np.sum(proba * np.log(proba / consensus), axis=2)

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

2 participants