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

EPIG implementation #270

Merged
merged 4 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions baal/active/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ def get_heuristic(
"variance": heuristics.Variance,
"precomputed": heuristics.Precomputed,
"batch_bald": heuristics.BatchBALD,
"epig": heuristics.EPIG,
}[name](shuffle_prop=shuffle_prop, reduction=reduction, **kwargs)
return heuristic
13 changes: 12 additions & 1 deletion baal/active/active_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,21 @@ def step(self, pool=None) -> bool:
if len(pool) > 0:
if isinstance(self.heuristic, heuristics.Random):
probs = np.random.uniform(low=0, high=1, size=(len(pool), 1))
targets = None
else:
probs = self.get_probabilities(pool, **self.kwargs)
if isinstance(self.heuristic, heuristics.EPIG):
targets = self.get_probabilities(self.dataset, **self.kwargs)
else:
targets = None
if probs is not None and (isinstance(probs, types.GeneratorType) or len(probs) > 0):
to_label, uncertainty = self.heuristic.get_ranks(probs)
to_label, uncertainty = self.heuristic.get_ranks(probs, targets)
log.info(
"Uncertainty",
mean=uncertainty.mean(),
std=uncertainty.std(),
median=np.median(uncertainty),
)
if indices is not None:
to_label = indices[np.array(to_label)]
if self.uncertainty_folder is not None:
Expand Down
Loading
Loading