예제 #1
0
파일: tuner.py 프로젝트: mort8Q/polyaxon
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),
    )
예제 #2
0
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")
예제 #3
0
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,
    )