Skip to content

Commit

Permalink
fix(ifbo): Better mapping of lowest fidelity to _near_ 0
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebergman committed Jan 26, 2025
1 parent 5225a6f commit 7755a73
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions neps/optimizers/ifbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

# NOTE: Ifbo was trained using 32 bit
FTPFN_DTYPE = torch.float32
BUDGET_DOMAIN_EPS = 1e-6


def _adjust_space_to_match_stepsize(
Expand Down Expand Up @@ -147,10 +148,24 @@ def __call__(
# Hence we use the two domains below to do so.

# Domain in which we should pass budgets to ifbo model
budget_domain = Domain.floating(lower=1 / fidelity.upper, upper=1)
# IFBO expects them to be in `(0 1]`, where explicitly 0 is
# not allowed. We map this close to `BUDGET_DOMAIN_EPS` depending
# on the scale of the fidelity domain.
budget_domain = Domain.floating(
lower=(fidelity.lower + BUDGET_DOMAIN_EPS)
/ (fidelity.upper - fidelity.lower),
upper=1,
)

# However, we need to make sure we don't end up with a positive
# `lower=` which gauranteed with this assertion.
if fidelity.upper - fidelity.lower < BUDGET_DOMAIN_EPS:
raise ValueError(
f"Fidelity domain {fidelity} is too small to be used with ifBO."
)

# Domain from which we assign an index to each budget
budget_index_domain = Domain.indices(self.n_fidelity_bins)
budget_index_domain = Domain.indices(self.n_fidelity_bins + 1)

# If we havn't passed the intial design phase
if new_id <= self.n_initial_design:
Expand Down

0 comments on commit 7755a73

Please sign in to comment.