MilesCranmer commited on
Commit
7acfb32
1 Parent(s): 5a4ff06

Fix parts of hyperparam optimization

Browse files
Files changed (1) hide show
  1. benchmarks/hyperparamopt.py +11 -6
benchmarks/hyperparamopt.py CHANGED
@@ -9,7 +9,7 @@ from hyperopt.fmin import generate_trials_to_calculate
9
 
10
  # Change the following code to your file
11
  ################################################################################
12
- TRIALS_FOLDER = "trials"
13
  NUMBER_TRIALS_PER_RUN = 1
14
  timeout_in_minutes = 5
15
 
@@ -252,7 +252,7 @@ def merge_trials(trials1, trials2_slice):
252
  max_tid = max([trial["tid"] for trial in trials1.trials])
253
 
254
  for trial in trials2_slice:
255
- tid = trial["tid"] + max_tid + 1
256
  local_hyperopt_trial = Trials().new_trial_docs(
257
  tids=[None], specs=[None], results=[None], miscs=[None]
258
  )
@@ -266,20 +266,25 @@ def merge_trials(trials1, trials2_slice):
266
  return trials1
267
 
268
 
 
 
 
 
269
  loaded_fnames = []
270
  trials = generate_trials_to_calculate(init_vals)
271
- i = 0
272
  n = NUMBER_TRIALS_PER_RUN
273
 
 
 
 
274
  # Run new hyperparameter trials until killed
275
  while True:
276
  np.random.seed()
277
 
278
  # Load up all runs:
279
- import glob
280
 
281
  if i > 0:
282
- path = TRIALS_FOLDER + "/*.pkl"
283
  for fname in glob.glob(path):
284
  if fname in loaded_fnames:
285
  continue
@@ -316,7 +321,7 @@ while True:
316
  run_trial,
317
  space=space,
318
  algo=tpe.suggest,
319
- max_evals=2,
320
  trials=trials,
321
  points_to_evaluate=init_vals,
322
  )
 
9
 
10
  # Change the following code to your file
11
  ################################################################################
12
+ TRIALS_FOLDER = "trials2"
13
  NUMBER_TRIALS_PER_RUN = 1
14
  timeout_in_minutes = 5
15
 
 
252
  max_tid = max([trial["tid"] for trial in trials1.trials])
253
 
254
  for trial in trials2_slice:
255
+ tid = trial["tid"] + max_tid + 2
256
  local_hyperopt_trial = Trials().new_trial_docs(
257
  tids=[None], specs=[None], results=[None], miscs=[None]
258
  )
 
266
  return trials1
267
 
268
 
269
+ import glob
270
+ path = TRIALS_FOLDER + "/*.pkl"
271
+ n_prior_trials = len(list(glob.glob(path)))
272
+
273
  loaded_fnames = []
274
  trials = generate_trials_to_calculate(init_vals)
275
+ i = n_prior_trials
276
  n = NUMBER_TRIALS_PER_RUN
277
 
278
+ if i > 0:
279
+ trials = None
280
+
281
  # Run new hyperparameter trials until killed
282
  while True:
283
  np.random.seed()
284
 
285
  # Load up all runs:
 
286
 
287
  if i > 0:
 
288
  for fname in glob.glob(path):
289
  if fname in loaded_fnames:
290
  continue
 
321
  run_trial,
322
  space=space,
323
  algo=tpe.suggest,
324
+ max_evals=1,
325
  trials=trials,
326
  points_to_evaluate=init_vals,
327
  )