sparta.common.tuning¶
-
class
sparta.common.tuning.TunableItemCfg(_type: str, _value: Union[Dict, List], _is_nested: Optional[bool] = False)[source]¶ -
TunableItemCfg is used to describe the search space .. rubric:: Examples
pythoncfg = TunableItemCfg('choice', _is_nested=True, _value={ 'openai': {}, 'sparta': { 'BM': TunableItemCfg('choice', [32,64]), 'BN': TunableItemCfg('choice', [8,16]), } }) nni_space = { 'test': {'_type':'choice', '_value': [ {'_name': 'openai'}, { '_name': 'sparta', 'BM': {'_type': 'choice', '_value': [32,64]}, 'BN': {'_type': 'choice', '_value': [8,16]}, }]} } # converted to a `NNI` search space (See more in https://nni.readthedocs.io/en/stable/hpo/search_space.html) assert search_space_cfg.to_nni_search_space() == nni_space- Parameters
_type (str) – paramter type, allowed one of (‘choice’).
_value (Dict | List) – options for paramter.
_is_nested (bool) – whether this space is nested (default: False). If True, the _value should be Dict[str, Dict[TunableItemCfg]]
-
class
sparta.common.tuning.Tunable[source]¶ -
The wrapper of NNI tuners that supports nested choice search space.
-
static
create_tuner(algo: str, search_space_cfg: Dict[str, TunableItemCfg], tuner_kw: Optional[Dict] = None)[source]¶ -
create NNI Tuner
- Parameters
algo (str) –
tuning algorithm, allowed algo values and their corresponding tuners are:
algo
tuner
grid
nni.algorithms.hpo.gridsearch_tuner.GridSearchTuner
rand
nni.algorithms.hpo.random_tuner.RandomTuner
tpe
nni.algorithms.hpo.tpe_tuner.TpeTuner
evolution
nni.algorithms.hpo.evolution_tuner.EvolutionTuner
search_space_cfg (TunableItemCfg) – search space config
tuner_kw (Dict) – parameters passed to NNI tuner
-
static