Skip to content

Commit

Permalink
Merge branch 'main' of github.com:automl/hypersweeper
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamc committed May 16, 2024
2 parents e3f53f7 + 9318d31 commit 4eaa60f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/configs/rs_branin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ hydra:
n_trials: 10
sweeper_kwargs:
max_parallelization: 0.8
max_budget: 100
search_space:
seed: 0
hyperparameters:
Expand Down
21 changes: 15 additions & 6 deletions hydra_plugins/hypersweeper/hypersweeper_sweeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ def record_iteration(self, performances, configs, budgets):
for i in range(len(configs)):
self.history["configs"].append(configs[i])
self.history["performances"].append(performances[i])
self.history["budgets"].append(budgets[i])
if budgets[i] is not None:
self.history["budgets"].append(budgets[i])
else:
self.history["budgets"].append(self.max_budget)
self.iteration += 1

if self.wandb_project:
Expand Down Expand Up @@ -392,14 +395,20 @@ def write_history(self):
configs = [c.get_dictionary() for c in self.history["configs"]]
performances = self.history["performances"]
budgets = self.history["budgets"]
keywords = ",".join(
["run_id", "budget", "performance"] + [str(k) for k in configs[0]]
)
keywords = ["run_id", "budget", "performance"] + [str(k) for k in self.configspace.get_hyperparameter_names()]
with open(Path(self.output_dir) / "runhistory.csv", "a+") as f:
f.write(f"{keywords}\n")
f.write(f"{','.join(keywords)}\n")
for i in range(len(configs)):
current_config = configs[i]
config_str = ",".join([str(current_config[k]) for k in current_config])
line = []
for k in keywords[3:]:
if k in current_config.keys():
line.append(current_config[k])
elif k in self.global_overrides:
line.append(self.global_overrides[k])
else:
line.append("None")
config_str = ",".join([str(l) for l in line])
f.write(f"{i},{budgets[i]},{performances[i]},{config_str}\n")

def run(self, verbose=False):
Expand Down

0 comments on commit 4eaa60f

Please sign in to comment.