def get_trial_index(experiment, fold, params):
# Check whether we are in a new configuration; This has to check whether
# the params were already inserted but also whether the fold already run
# This is checked twice; the instance_result has to be not NaN and the
# entry in instance_order has to exist
new = True
trial_index = np.NaN
for idx, trial in enumerate(experiment.trials):
exp = trial['params']
if exp == params and (idx, fold) not in experiment.instance_order and \
(experiment.get_trial_from_id(idx)['instance_results'][fold] == np.NaN or
experiment.get_trial_from_id(idx)['instance_results'][fold] !=
experiment.get_trial_from_id(idx)['instance_results'][fold]):
new = False
trial_index = idx
break
if new:
trial_index = experiment.add_job(params)
return trial_index
评论列表
文章目录