Optuna sample fixed parameter depending on another parameter
Asked Answered
C

0

7

In my setting I have an abstract situation like the following, which shall only function as an example case:

base = trial.suggest_int(1, 3)
power = trial.suggest_int(1, 10)
# value = base ** power

As when the base == 1 the power parameter becomes irrelevant and I would like to fix it to 1.

For example:

base = trial.suggest_int("base", 1, 3)
if base == 1:
   # Different distribution! But still inside the other.
   power = trial.suggest_int("power", 1, 1) 
else:
   power = trial.suggest_int("power", 1, 10)

While this works it creates later problems in the form of ValueErrors because the underlying distributions are not the same.


How can I suggest a fixed value with the same parameter name that depends on another value that is sampled within the trial?

Chambliss answered 4/3, 2023 at 12:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.