Skip to content

Commit

Permalink
seeding for HyperNePS
Browse files Browse the repository at this point in the history
  • Loading branch information
becktepe committed Sep 15, 2024
1 parent 804b524 commit 86ec790
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/configs/mlp_neps_priorband.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ activation: tanh

seed: 42
epochs: 10 # Default number of epochs
neps_seed: 0

hydra:
sweeper:
Expand All @@ -26,6 +27,7 @@ hydra:
fidelity_variable: ${hydra.sweeper.budget_variable}
min_budget: 5
max_budget: 50
seed: ${neps_seed}
optimizer:
_target_: neps.optimizers.multi_fidelity_prior.priorband.PriorBand
_partial_: true
Expand All @@ -42,6 +44,7 @@ hydra:
inc_mutation_std: 0.25
inc_style: dynamic
search_space:
seed: ${neps_seed}
hyperparameters:
n_layer:
type: uniform_int
Expand Down
6 changes: 6 additions & 0 deletions hydra_plugins/hyper_neps/hyper_neps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import time
from pathlib import Path
import math
import numpy as np
import random


if (spec := importlib.util.find_spec("neps")) is not None:
Expand Down Expand Up @@ -84,6 +86,10 @@ def tell(self, info: Info, value):

def make_neps(configspace, hyper_neps_args):
"""Make a NEPS instance for optimization."""
# important for NePS optimizers
random.seed(hyper_neps_args["seed"])
np.random.seed(hyper_neps_args["seed"])

dict_search_space = get_dict_from_configspace(configspace)

dict_search_space[hyper_neps_args["fidelity_variable"]] = neps.IntegerParameter(
Expand Down

0 comments on commit 86ec790

Please sign in to comment.