From d77ac84d7f535bddad675ee636c4215407d70c5f Mon Sep 17 00:00:00 2001 From: Dref360 Date: Mon, 2 Oct 2023 15:46:30 -0400 Subject: [PATCH] Add aliases for powerbald and powerentropy --- baal/active/heuristics/aliases.py | 17 +++++++++++++++++ docs/user_guide/heuristics.md | 6 ++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 baal/active/heuristics/aliases.py diff --git a/baal/active/heuristics/aliases.py b/baal/active/heuristics/aliases.py new file mode 100644 index 00000000..a4a12aa6 --- /dev/null +++ b/baal/active/heuristics/aliases.py @@ -0,0 +1,17 @@ +"""Some heuristics are simply combinations of others.""" +from typing import Union, Callable + +from baal.active.heuristics import BALD, Entropy +from baal.active.heuristics.stochastics import PowerSampling + + +def PowerBALD(query_size: int, temperature: float = 1.0, reduction: Union[str, Callable] = "none"): + return PowerSampling(BALD(reduction=reduction), query_size=query_size, temperature=temperature) + + +def PowerEntropy( + query_size: int, temperature: float = 1.0, reduction: Union[str, Callable] = "none" +): + return PowerSampling( + Entropy(reduction=reduction), query_size=query_size, temperature=temperature + ) diff --git a/docs/user_guide/heuristics.md b/docs/user_guide/heuristics.md index 55117b6b..6d41a61c 100644 --- a/docs/user_guide/heuristics.md +++ b/docs/user_guide/heuristics.md @@ -33,11 +33,9 @@ This approach is on-par with methods like BADGE or BatchBALD, while being hundre To use PowerBALD in your code, it is as simple as: ``` - from baal.active.heuristics import BALD - from baal.active.heuristics.stochastics import PowerSampling + from baal.active.heuristics.aliases import PowerBALD - - heuristic = PowerSampling(BALD(), query_size=QUERY_SIZE, temperature=1.0) + heuristic = PowerBALD(query_size=QUERY_SIZE, temperature=1.0) ``` ### BALD