Skip to content

Commit

Permalink
Use environment variable to provide seed to fmin (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmcgill committed Feb 18, 2022
1 parent ebd2779 commit b74cd6c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion chemprop/hyperparameter_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def objective(hyperparams: Dict[str, Union[int, float]], seed: int) -> Dict:
# Set a unique random seed for each trial. Pass it into objective function for logging purposes.
hyperopt_seed = get_hyperopt_seed(seed=args.seed, dir_path=args.hyperopt_checkpoint_dir)
fmin_objective = partial(objective, seed=hyperopt_seed)
os.environ['HYPEROPT_FMIN_SEED'] = str(hyperopt_seed) # this environment variable changes the seed in fmin

# Log the start of the trial
logger.info(f'Initiating trial with seed {hyperopt_seed}')
Expand All @@ -132,7 +133,6 @@ def objective(hyperparams: Dict[str, Union[int, float]], seed: int) -> Dict:
algo=partial(tpe.suggest, n_startup_jobs=args.startup_random_iters),
max_evals=len(trials) + 1,
trials=trials,
rstate=np.random.RandomState(hyperopt_seed),
)

# Create a trials object with only the last instance by merging the last data with an empty trials object
Expand Down

0 comments on commit b74cd6c

Please sign in to comment.