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

fix: no pool preds for random heuristic #277

Merged
merged 4 commits into from Sep 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion baal/active/active_loop.py
Expand Up @@ -79,7 +79,10 @@ def step(self, pool=None) -> bool:
indices = None

if len(pool) > 0:
probs = self.get_probabilities(pool, **self.kwargs)
if self.heuristic.__class__.__name__ == "Random":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use isinstance(self.heuristic, Random) here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment! I added a unit test that checks whether self.get_probabilities is called with unittest.mock.patch.

probs = np.random.uniform(low=0, high=1, size=(len(pool), 1))
else:
probs = self.get_probabilities(pool, **self.kwargs)
if probs is not None and (isinstance(probs, types.GeneratorType) or len(probs) > 0):
to_label, uncertainty = self.heuristic.get_ranks(probs)
if indices is not None:
Expand Down