2020-09-05 02:39:51 +01:00
|
|
|
.. _tune-search-space:
|
2020-04-06 12:16:35 -07:00
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
Search Space API
|
|
|
|
================
|
2021-10-29 10:45:29 +01:00
|
|
|
|
2020-03-23 12:23:21 -07:00
|
|
|
.. _tune-sample-docs:
|
|
|
|
|
2020-04-06 12:16:35 -07:00
|
|
|
Random Distributions API
|
|
|
|
------------------------
|
2020-03-23 12:23:21 -07:00
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
This section covers the functions you can use to define your search spaces.
|
2020-03-23 12:23:21 -07:00
|
|
|
|
2021-10-29 10:45:29 +01:00
|
|
|
.. caution::
|
|
|
|
|
2022-02-27 08:07:34 +01:00
|
|
|
Not all Search Algorithms support all distributions. In particular,
|
|
|
|
``tune.sample_from`` and ``tune.grid_search`` are often unsupported.
|
2021-10-29 10:45:29 +01:00
|
|
|
The default :ref:`tune-basicvariant` supports all distributions.
|
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
For a high-level overview, see this example:
|
2020-03-23 12:23:21 -07:00
|
|
|
|
2022-02-27 08:07:34 +01:00
|
|
|
.. TODO: test this
|
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
.. code-block :: python
|
2020-09-03 17:06:13 +01:00
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
config = {
|
|
|
|
# Sample a float uniformly between -5.0 and -1.0
|
|
|
|
"uniform": tune.uniform(-5, -1),
|
2020-09-03 17:06:13 +01:00
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
# Sample a float uniformly between 3.2 and 5.4,
|
|
|
|
# rounding to increments of 0.2
|
|
|
|
"quniform": tune.quniform(3.2, 5.4, 0.2),
|
2020-03-23 12:23:21 -07:00
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
# Sample a float uniformly between 0.0001 and 0.01, while
|
|
|
|
# sampling in log space
|
|
|
|
"loguniform": tune.loguniform(1e-4, 1e-2),
|
2020-03-23 12:23:21 -07:00
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
# Sample a float uniformly between 0.0001 and 0.1, while
|
2021-08-03 14:48:22 +01:00
|
|
|
# sampling in log space and rounding to increments of 0.00005
|
|
|
|
"qloguniform": tune.qloguniform(1e-4, 1e-1, 5e-5),
|
2020-09-03 17:06:13 +01:00
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
# Sample a random float from a normal distribution with
|
|
|
|
# mean=10 and sd=2
|
|
|
|
"randn": tune.randn(10, 2),
|
|
|
|
|
|
|
|
# Sample a random float from a normal distribution with
|
|
|
|
# mean=10 and sd=2, rounding to increments of 0.2
|
|
|
|
"qrandn": tune.qrandn(10, 2, 0.2),
|
|
|
|
|
|
|
|
# Sample a integer uniformly between -9 (inclusive) and 15 (exclusive)
|
|
|
|
"randint": tune.randint(-9, 15),
|
|
|
|
|
|
|
|
# Sample a random uniformly between -21 (inclusive) and 12 (inclusive (!))
|
|
|
|
# rounding to increments of 3 (includes 12)
|
|
|
|
"qrandint": tune.qrandint(-21, 12, 3),
|
|
|
|
|
2021-06-11 15:31:08 +02:00
|
|
|
# Sample a integer uniformly between 1 (inclusive) and 10 (exclusive),
|
|
|
|
# while sampling in log space
|
|
|
|
"lograndint": tune.lograndint(1, 10),
|
|
|
|
|
2020-12-23 18:27:16 +01:00
|
|
|
# Sample a integer uniformly between 1 (inclusive) and 10 (inclusive (!)),
|
|
|
|
# while sampling in log space and rounding to increments of 2
|
|
|
|
"qlograndint": tune.qlograndint(1, 10, 2),
|
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
# Sample an option uniformly from the specified choices
|
|
|
|
"choice": tune.choice(["a", "b", "c"]),
|
|
|
|
|
|
|
|
# Sample from a random function, in this case one that
|
|
|
|
# depends on another value from the search space
|
|
|
|
"func": tune.sample_from(lambda spec: spec.config.uniform * 0.01),
|
|
|
|
|
|
|
|
# Do a grid search over these values. Every value will be sampled
|
|
|
|
# `num_samples` times (`num_samples` is the parameter you pass to `tune.run()`)
|
|
|
|
"grid": tune.grid_search([32, 64, 128])
|
|
|
|
}
|
2020-09-03 17:06:13 +01:00
|
|
|
|
2020-03-23 12:23:21 -07:00
|
|
|
tune.uniform
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.uniform
|
|
|
|
|
2020-09-03 17:06:13 +01:00
|
|
|
tune.quniform
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.quniform
|
|
|
|
|
2020-09-05 02:39:51 +01:00
|
|
|
tune.loguniform
|
|
|
|
~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.loguniform
|
|
|
|
|
|
|
|
tune.qloguniform
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.qloguniform
|
|
|
|
|
|
|
|
tune.randn
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.randn
|
|
|
|
|
|
|
|
tune.qrandn
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.qrandn
|
|
|
|
|
2020-09-03 17:06:13 +01:00
|
|
|
tune.randint
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.randint
|
|
|
|
|
|
|
|
tune.qrandint
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.qrandint
|
|
|
|
|
2021-06-11 15:31:08 +02:00
|
|
|
tune.lograndint
|
|
|
|
~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.lograndint
|
|
|
|
|
|
|
|
tune.qlograndint
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.qlograndint
|
|
|
|
|
2020-03-23 12:23:21 -07:00
|
|
|
tune.choice
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
|
|
.. autofunction:: ray.tune.choice
|
|
|
|
|
|
|
|
tune.sample_from
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
2020-09-03 17:06:13 +01:00
|
|
|
.. autofunction:: ray.tune.sample_from
|
2020-03-23 12:23:21 -07:00
|
|
|
|
2020-04-06 12:16:35 -07:00
|
|
|
Grid Search API
|
|
|
|
---------------
|
2020-03-23 12:23:21 -07:00
|
|
|
|
|
|
|
.. autofunction:: ray.tune.grid_search
|
|
|
|
|
2020-12-18 04:16:03 +01:00
|
|
|
References
|
|
|
|
----------
|
2020-03-23 12:23:21 -07:00
|
|
|
|
2020-12-23 18:27:16 +01:00
|
|
|
See also :ref:`tune-basicvariant`.
|