Skip to content

Commit

Permalink
j026
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcardoso committed Aug 19, 2023
1 parent 5adf4e1 commit 010d9f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions mergernet/estimators/automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def __init__(
pruner: str = 'hyperband',
objective_metric: str = 'val_loss',
objective_direction: str = 'minimize',
resume_hash: str = None,
resume: bool = False,
):
super().__init__(estimator.hp, estimator.dataset)
self.estimator = estimator
self.n_trials = n_trials
self.pruner = pruner
self.objective_metric = objective_metric
self.objective_direction = objective_direction
self.resume_hash = resume_hash
self.resume = resume


def _objective(self, trial: optuna.trial.Trial) -> float:
Expand Down Expand Up @@ -124,15 +124,13 @@ def train(self, *args, **kwargs) -> Tuple[tf.keras.Model, tf.keras.callbacks.His
optuna_path = Experiment.local_exp_path / OPTUNA_DB_FILENAME
optuna_uri = f'sqlite:///{str(optuna_path.resolve())}' # absolute path

if self.resume_hash is not None:
# creating a new study instance
if self.resume:
L.info(f'Downloading optuna study of exp {exp_id}')
Experiment.download_file_gh(OPTUNA_DB_FILENAME, exp_id)

# creating a new study instance
if self.resume_hash is None:
study_factory = optuna.create_study
else:
study_factory = optuna.load_study
else:
study_factory = optuna.create_study

study = study_factory(
storage=optuna_uri,
Expand Down
2 changes: 1 addition & 1 deletion mergernet/jobs/j026.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def call(self):

model = ParametricEstimator(hp=hps, dataset=ds)

optuna_model = OptunaEstimator(estimator=model, n_trials=70)
optuna_model = OptunaEstimator(estimator=model, n_trials=20, resume=True)

optuna_model.train()

Expand Down

0 comments on commit 010d9f5

Please sign in to comment.