def bayesian(matrix, configs, metrics): """Create suggestions based on bayesian optimization.""" from polyaxon.polyflow import V1Bayes from polyaxon.polytune.search_managers.bayesian_optimization.manager import ( BayesSearchManager, ) matrix = V1Bayes.read(matrix) suggestions = BayesSearchManager(config=matrix).get_suggestions( configs=configs, metrics=metrics) log_suggestions(suggestions) Printer.print_success("Suggestions generated with bayesian optimization")
def bayes(matrix, join, iteration): """Create suggestions based on bayesian optimization.""" from polyaxon.client import RunClient from polyaxon.polyflow import V1Bayes, V1Join from polyaxon.polytune.iteration_lineage import ( get_iteration_definition, handle_iteration, handle_iteration_failure, ) from polyaxon.polytune.search_managers.bayesian_optimization.manager import ( BayesSearchManager, ) matrix = V1Bayes.read(matrix) join = V1Join.read(join) client = RunClient() values = get_iteration_definition( client=client, iteration=iteration, join=join, optimization_metric=matrix.metric.name, ) if not values: return run_uuids, configs, metrics = values retry = 1 exp = None suggestions = None while retry < 3: try: suggestions = BayesSearchManager(config=matrix, ).get_suggestions( configs=configs, metrics=metrics) 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, )
def get_bo_tuner( matrix: V1Bayes, join: V1Join, iteration: int, ) -> V1Operation: iteration = matrix.create_iteration(iteration) return get_tuner( name="bayesian-tuner", container=get_container( tuner_container=get_default_tuner_container( ["polyaxon", "tuner", "bayes"]), container=matrix.container, ), matrix=matrix, join=join, iteration=iteration, )
def bayes(matrix, configs, metrics, iteration): """Create suggestions based on bayesian optimization.""" from polyaxon.client import RunClient from polyaxon.polyflow import V1Bayes from polyaxon.polytune.iteration_lineage import ( handle_iteration, handle_iteration_failure, ) from polyaxon.polytune.search_managers.bayesian_optimization.manager import ( BayesSearchManager, ) matrix = V1Bayes.read(matrix) 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 = BayesSearchManager(config=matrix, ).get_suggestions( configs=configs, metrics=metrics) 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, )