mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00
[hotfix] Lint formatting for new Tune optimizer ZOOpt (#8040)
* formatting * removedill * lint
This commit is contained in:
parent
d4cae5f632
commit
4d8bf5635d
6 changed files with 21 additions and 12 deletions
|
@ -32,7 +32,8 @@ MOCK_MODULES = [
|
||||||
"tensorflow.contrib.rnn", "tensorflow.contrib.slim", "tensorflow.core",
|
"tensorflow.contrib.rnn", "tensorflow.contrib.slim", "tensorflow.core",
|
||||||
"tensorflow.core.util", "tensorflow.python", "tensorflow.python.client",
|
"tensorflow.core.util", "tensorflow.python", "tensorflow.python.client",
|
||||||
"tensorflow.python.util", "torch", "torch.distributed", "torch.nn",
|
"tensorflow.python.util", "torch", "torch.distributed", "torch.nn",
|
||||||
"torch.nn.parallel", "torch.utils.data", "torch.utils.data.distributed"
|
"torch.nn.parallel", "torch.utils.data", "torch.utils.data.distributed",
|
||||||
|
"zoopt"
|
||||||
]
|
]
|
||||||
for mod_name in MOCK_MODULES:
|
for mod_name in MOCK_MODULES:
|
||||||
sys.modules[mod_name] = mock.Mock()
|
sys.modules[mod_name] = mock.Mock()
|
||||||
|
|
|
@ -48,6 +48,11 @@ SkOptSearch
|
||||||
|
|
||||||
.. autoclass:: ray.tune.suggest.skopt.SkOptSearch
|
.. autoclass:: ray.tune.suggest.skopt.SkOptSearch
|
||||||
|
|
||||||
|
ZOOptSearch
|
||||||
|
-----------
|
||||||
|
|
||||||
|
.. autoclass:: ray.tune.suggest.zoopt.ZOOptSearch
|
||||||
|
|
||||||
SearchAlgorithm
|
SearchAlgorithm
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
|
|
@ -28,4 +28,3 @@ torch
|
||||||
torchvision
|
torchvision
|
||||||
xgboost
|
xgboost
|
||||||
zoopt>=0.4.0
|
zoopt>=0.4.0
|
||||||
dill
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
"""This test checks that ZOOpt is functional.
|
"""This test checks that ZOOptSearch is functional.
|
||||||
|
|
||||||
It also checks that it is usable with a separate scheduler.
|
It also checks that it is usable with a separate scheduler.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import ray
|
import ray
|
||||||
from ray.tune import run
|
from ray.tune import run
|
||||||
from ray.tune.suggest.zoopt import ZOOptSearch
|
from ray.tune.suggest.zoopt import ZOOptSearch
|
||||||
|
@ -39,7 +38,7 @@ if __name__ == "__main__":
|
||||||
}
|
}
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
"num_samples": 200 if args.smoke_test else 1000,
|
"num_samples": 10 if args.smoke_test else 1000,
|
||||||
"config": {
|
"config": {
|
||||||
"iterations": 10, # evaluation times
|
"iterations": 10, # evaluation times
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import dill as pickle
|
import ray.cloudpickle as pickle
|
||||||
from zoopt import Dimension2, Parameter
|
|
||||||
from zoopt.algos.opt_algorithms.racos.sracos import SRacosTune
|
try:
|
||||||
|
import zoopt
|
||||||
|
except ImportError:
|
||||||
|
zoopt = None
|
||||||
|
|
||||||
from ray.tune.suggest.suggestion import SuggestionAlgorithm
|
from ray.tune.suggest.suggestion import SuggestionAlgorithm
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -76,7 +80,7 @@ class ZOOptSearch(SuggestionAlgorithm):
|
||||||
metric="episode_reward_mean",
|
metric="episode_reward_mean",
|
||||||
mode="min",
|
mode="min",
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
assert zoopt is not None, "Zoopt not found - please install zoopt."
|
||||||
assert budget is not None, "`budget` should not be None!"
|
assert budget is not None, "`budget` should not be None!"
|
||||||
assert dim_dict is not None, "`dim_list` should not be None!"
|
assert dim_dict is not None, "`dim_list` should not be None!"
|
||||||
assert type(max_concurrent) is int and max_concurrent > 0
|
assert type(max_concurrent) is int and max_concurrent > 0
|
||||||
|
@ -99,9 +103,10 @@ class ZOOptSearch(SuggestionAlgorithm):
|
||||||
self._dim_keys.append(k)
|
self._dim_keys.append(k)
|
||||||
_dim_list.append(dim_dict[k])
|
_dim_list.append(dim_dict[k])
|
||||||
|
|
||||||
dim = Dimension2(_dim_list)
|
dim = zoopt.Dimension2(_dim_list)
|
||||||
par = Parameter(budget=budget)
|
par = zoopt.Parameter(budget=budget)
|
||||||
if _algo == "sracos" or _algo == "asracos":
|
if _algo == "sracos" or _algo == "asracos":
|
||||||
|
from zoopt.algos.opt_algorithms.racos.sracos import SRacosTune
|
||||||
self.optimizer = SRacosTune(dimension=dim, parameter=par)
|
self.optimizer = SRacosTune(dimension=dim, parameter=par)
|
||||||
|
|
||||||
self.solution_dict = {}
|
self.solution_dict = {}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import skopt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from hyperopt import hp
|
from hyperopt import hp
|
||||||
from nevergrad.optimization import optimizerlib
|
from nevergrad.optimization import optimizerlib
|
||||||
|
from zoopt import ValueType
|
||||||
|
|
||||||
import ray
|
import ray
|
||||||
from ray import tune
|
from ray import tune
|
||||||
|
@ -18,7 +19,6 @@ from ray.tune.suggest.skopt import SkOptSearch
|
||||||
from ray.tune.suggest.nevergrad import NevergradSearch
|
from ray.tune.suggest.nevergrad import NevergradSearch
|
||||||
from ray.tune.suggest.sigopt import SigOptSearch
|
from ray.tune.suggest.sigopt import SigOptSearch
|
||||||
from ray.tune.suggest.zoopt import ZOOptSearch
|
from ray.tune.suggest.zoopt import ZOOptSearch
|
||||||
from zoopt import ValueType
|
|
||||||
from ray.tune.utils import validate_save_restore
|
from ray.tune.utils import validate_save_restore
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue