def simple_launch(task_name, script_args): """Launch the task without creating another python interpreter""" module = __import__("olympus.baselines.{}".format(task_name), fromlist=['']) parser = module.arguments() args = parse_args(parser, script_args) module.main(**vars(args)) return None
def arguments(): parser = ArgumentParser(prog='finance', description='Finance Baseline', epilog=show_hyperparameter_space(), formatter_class=RawDescriptionHelpFormatter) parser.add_argument('--uri', type=str, default=None, help='Resource to use to store metrics') parser.add_argument('--database', type=str, default='olympus', help='which database to use') parser.add_argument('--arg-file', type=str, default=None, metavar='ARGS', help='Json File containing the arguments to use') parser.add_argument('--optimizer', type=str, default='adam', metavar='OPTIMIZER_NAME', choices=known_optimizers(), help='Name of the optimiser (default: adam)') parser.add_argument('--batch-size', type=int, default=32, metavar='B', help='input batch size for training (default: 32)') parser.add_argument( '--epochs', type=int, default=100, metavar='N', help='maximum number of epochs to train (default: 100)') parser.add_argument('--window', type=int, default=70, metavar='W', help='Windown timeframe in days (default: 70)') parser.add_argument('--storage', action='store_true', default=False, help='Enable storage') return parse_args(parser)
hpo_task = HPO(hpo, main_task) hpo_task.metrics.append(ElapsedRealTime()) trial = hpo_task.fit(objective='validation_accuracy') print(f'HPO is done, objective: {trial.objective}') params = trial.params else: print('No hyper parameter missing, running the experiment...') # ------ # Run the experiment with the best hyper parameters # ------------------------------------------------- if params is not None: # Train using train + valid for the final result final_task = classification_baseline(device=device, **kwargs, hpo_done=True) final_task.init(**params) final_task.fit(epochs=args.epochs) print('=' * 40) print('Final Trial Results') show_dict(flatten(params)) final_task.report(pprint=True, print_fun=print) print('=' * 40) if __name__ == '__main__': from olympus.utils import parse_args main(**vars(parse_args(arguments())))