[tune] Deprecate ambiguous function values (use tune.function / tune.sample_from instead) (#3457)

* wip

* exclude
This commit is contained in:
Eric Liang
2018-12-06 11:35:20 -08:00
committed by GitHub
parent d864f299d7
commit 412aaa5195
13 changed files with 96 additions and 39 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ ray.tune.suggest
.. automodule:: ray.tune.suggest
:members:
:exclude-members: function, grid_search, SuggestionAlgorithm
:exclude-members: function, sample_from, grid_search, SuggestionAlgorithm
:show-inheritance:
.. autoclass:: ray.tune.suggest.SuggestionAlgorithm
+5 -5
View File
@@ -141,8 +141,8 @@ The following shows grid search over two nested parameters combined with random
"my_experiment_name": {
"run": my_trainable,
"config": {
"alpha": lambda spec: np.random.uniform(100),
"beta": lambda spec: spec.config.alpha * np.random.normal(),
"alpha": tune.sample_from(lambda spec: np.random.uniform(100)),
"beta": tune.sample_from(lambda spec: spec.config.alpha * np.random.normal()),
"nn_layers": [
tune.grid_search([16, 64, 256]),
tune.grid_search([16, 64, 256]),
@@ -153,7 +153,7 @@ The following shows grid search over two nested parameters combined with random
.. note::
Lambda functions will be evaluated during trial variant generation. If you need to pass a literal function in your config, use ``tune.function(...)`` to escape it.
Use ``tune.sample_from(...)`` to sample from a function during trial variant generation. If you need to pass a literal function in your config, use ``tune.function(...)`` to escape it.
For more information on variant generation, see `basic_variant.py <https://github.com/ray-project/ray/blob/master/python/ray/tune/suggest/basic_variant.py>`__.
@@ -169,8 +169,8 @@ By default, each random variable and grid search point is sampled once. To take
"my_experiment_name": {
"run": my_trainable,
"config": {
"alpha": lambda spec: np.random.uniform(100),
"beta": lambda spec: spec.config.alpha * np.random.normal(),
"alpha": tune.sample_from(lambda spec: np.random.uniform(100)),
"beta": tune.sample_from(lambda spec: spec.config.alpha * np.random.normal()),
"nn_layers": [
tune.grid_search([16, 64, 256]),
tune.grid_search([16, 64, 256]),