Skip to content

Commit

Permalink
Add aliases for powerbald and powerentropy
Browse files Browse the repository at this point in the history
  • Loading branch information
Dref360 committed Oct 2, 2023
1 parent e76c93e commit d77ac84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
17 changes: 17 additions & 0 deletions baal/active/heuristics/aliases.py
Original file line number Diff line number Diff line change
@@ -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
)
6 changes: 2 additions & 4 deletions docs/user_guide/heuristics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d77ac84

Please sign in to comment.