def hyperband(matrix, join, iteration, bracket_iteration): """Create suggestions based on hyperband.""" from polyaxon.client import RunClient from polyaxon.polyflow import V1Hyperband, V1Join from polyaxon.polytune.iteration_lineage import ( get_iteration_definition, handle_iteration, handle_iteration_failure, ) from polyaxon.polytune.search_managers.hyperband.manager import HyperbandManager matrix = V1Hyperband.read(matrix) matrix.set_tuning_params() join = V1Join.read(join) client = RunClient() values = get_iteration_definition( client=client, iteration=iteration, join=join, optimization_metric=matrix.metric.name, name="in-iteration-{}-{}".format(iteration, bracket_iteration), ) if not values: return run_uuids, configs, metrics = values retry = 1 exp = None suggestions = None while retry < 3: try: suggestions = HyperbandManager(config=matrix).get_suggestions( configs=configs, metrics=metrics, bracket_iteration=bracket_iteration, iteration=iteration, ) exp = None break except Exception as exp: retry += 1 logger.warning(exp) if exp: handle_iteration_failure(client=client, exp=exp) return handle_iteration( client=client, iteration=iteration, suggestions=suggestions, summary={"bracket_iteration": bracket_iteration}, name="out-iteration-{}-{}".format(iteration, bracket_iteration), )
def get_hyperband_tuner( matrix: V1Hyperband, join: V1Join, iteration: int, bracket_iteration: int, ) -> V1Operation: matrix.set_tuning_params() iteration, bracket_iteration = matrix.create_iteration( iteration, bracket_iteration) return get_tuner( name="hyperband-tuner", container=get_container( tuner_container=get_default_tuner_container( ["polyaxon", "tuner", "hyperband"], bracket_iteration=bracket_iteration, ), container=matrix.container, ), matrix=matrix, join=join, iteration=iteration, bracket_iteration=bracket_iteration, )
def hyperband(matrix, iteration, bracket_iteration, configs, metrics): """Create suggestions based on hyperband.""" from polyaxon.polyflow import V1Hyperband from polyaxon.polytune.search_managers.hyperband.manager import HyperbandManager matrix = V1Hyperband.read(matrix) suggestions = HyperbandManager(config=matrix).get_suggestions( configs=configs, metrics=metrics, bracket_iteration=bracket_iteration, iteration=iteration, ) log_suggestions(suggestions) Printer.print_success("Suggestions generated with hyperband")
def hyperband(matrix, configs, metrics, iteration, bracket_iteration): """Create suggestions based on hyperband.""" from polyaxon.client import RunClient from polyaxon.polyflow import V1Hyperband from polyaxon.polytune.iteration_lineage import ( handle_iteration, handle_iteration_failure, ) from polyaxon.polytune.search_managers.hyperband.manager import HyperbandManager matrix = V1Hyperband.read(matrix) matrix.set_tuning_params() if configs: configs = ujson.loads(configs) if metrics: metrics = ujson.loads(metrics) client = RunClient() retry = 1 exp = None suggestions = None while retry < 3: try: suggestions = HyperbandManager(config=matrix).get_suggestions( configs=configs, metrics=metrics, bracket_iteration=bracket_iteration, iteration=iteration, ) exp = None break except Exception as e: retry += 1 logger.warning(e) exp = e if exp: handle_iteration_failure(client=client, exp=exp) return handle_iteration( client=client, suggestions=suggestions, )