Unverified Commit 12a5e3de authored by Yuge Zhang's avatar Yuge Zhang Committed by GitHub
Browse files

Refactor HPO tuner code hierarchy (#3187)


Co-authored-by: default avatarliuzhe <liuzhe.cs@pku.edu.cn>
parent 872554f1
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .medianstop_assessor import MedianstopAssessor
from .metis_tuner import MetisTuner, MetisClassArgsValidator
from .networkmorphism_tuner import NetworkMorphismTuner, NetworkMorphismClassArgsValidator
from .ppo_tuner import PPOTuner from .ppo_tuner import PPOTuner, PPOClassArgsValidator
from .regularized_evolution_tuner import RegularizedEvolutionTuner
# Copyright (c) Microsoft Corporation. # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license. # Licensed under the MIT license.
from .smac_tuner import SMACTuner from .smac_tuner import SMACTuner, SMACClassArgsValidator
git+https://github.com/QuanluZhang/ConfigSpace.git
git+https://github.com/QuanluZhang/SMAC3.git
...@@ -87,7 +87,7 @@ class ConfigBase: ...@@ -87,7 +87,7 @@ class ConfigBase:
""" """
return dataclasses.asdict( return dataclasses.asdict(
self.canonical(), self.canonical(),
dict_factory = lambda items: dict((util.camel_case(k), v) for k, v in items if v is not None) dict_factory=lambda items: dict((util.camel_case(k), v) for k, v in items if v is not None)
) )
def canonical(self: T) -> T: def canonical(self: T) -> T:
......
...@@ -32,7 +32,7 @@ def start_experiment(config: ExperimentConfig, port: int, debug: bool) -> Tuple[ ...@@ -32,7 +32,7 @@ def start_experiment(config: ExperimentConfig, port: int, debug: bool) -> Tuple[
exp_id = management.generate_experiment_id() exp_id = management.generate_experiment_id()
try: try:
_logger.info(f'Creating experiment {colorama.Fore.CYAN}{exp_id}') _logger.info('Creating experiment %s%s', colorama.Fore.CYAN, exp_id)
pipe = Pipe(exp_id) pipe = Pipe(exp_id)
proc = _start_rest_server(config, port, debug, exp_id, pipe.path) proc = _start_rest_server(config, port, debug, exp_id, pipe.path)
_logger.info('Connecting IPC pipe...') _logger.info('Connecting IPC pipe...')
......
from .base_mutator import BaseMutator
from .base_trainer import BaseTrainer
from .fixed import apply_fixed_architecture
from .mutables import Mutable, LayerChoice, InputChoice
from .mutator import Mutator
from .trainer import Trainer
...@@ -43,8 +43,8 @@ def get_registered_algo_meta(builtin_name, algo_type=None): ...@@ -43,8 +43,8 @@ def get_registered_algo_meta(builtin_name, algo_type=None):
------- -------
Returns meta information of speicified builtin alogorithms, for example: Returns meta information of speicified builtin alogorithms, for example:
{ {
'classArgsValidator': 'nni.smac_tuner.smac_tuner.SMACClassArgsValidator', 'classArgsValidator': 'nni.smac_tuner.SMACClassArgsValidator',
'className': 'nni.smac_tuner.smac_tuner.SMACTuner', 'className': 'nni.smac_tuner.SMACTuner',
'builtinName': 'SMAC' 'builtinName': 'SMAC'
} }
""" """
......
...@@ -11,22 +11,21 @@ import sys ...@@ -11,22 +11,21 @@ import sys
from collections import deque from collections import deque
from unittest import TestCase, main from unittest import TestCase, main
from nni.algorithms.hpo.batch_tuner.batch_tuner import BatchTuner from nni.algorithms.hpo.batch_tuner import BatchTuner
from nni.algorithms.hpo.evolution_tuner.evolution_tuner import EvolutionTuner from nni.algorithms.hpo.evolution_tuner import EvolutionTuner
from nni.algorithms.hpo.gp_tuner.gp_tuner import GPTuner from nni.algorithms.hpo.gp_tuner import GPTuner
from nni.algorithms.hpo.gridsearch_tuner.gridsearch_tuner import GridSearchTuner from nni.algorithms.hpo.gridsearch_tuner import GridSearchTuner
from nni.algorithms.hpo.hyperopt_tuner.hyperopt_tuner import HyperoptTuner from nni.algorithms.hpo.hyperopt_tuner import HyperoptTuner
from nni.algorithms.hpo.metis_tuner.metis_tuner import MetisTuner from nni.algorithms.hpo.metis_tuner import MetisTuner
from nni.algorithms.hpo.pbt_tuner.pbt_tuner import PBTTuner from nni.algorithms.hpo.pbt_tuner import PBTTuner
from nni.algorithms.hpo.regularized_evolution_tuner.regularized_evolution_tuner import RegularizedEvolutionTuner from nni.algorithms.hpo.regularized_evolution_tuner import RegularizedEvolutionTuner
from nni.runtime.msg_dispatcher import _pack_parameter, MsgDispatcher from nni.runtime.msg_dispatcher import _pack_parameter, MsgDispatcher
if sys.platform != 'win32': if sys.platform != 'win32':
from nni.algorithms.hpo.smac_tuner.smac_tuner import SMACTuner from nni.algorithms.hpo.smac_tuner import SMACTuner
from nni.tuner import Tuner from nni.tuner import Tuner
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('test_tuner') logger = logging.getLogger('test_tuner')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment