Skip to content

Commit

Permalink
Fix comments to reflect review points.
Browse files Browse the repository at this point in the history
  • Loading branch information
toshihikoyanase committed Jul 26, 2019
1 parent 922b418 commit 119372d
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions optuna/integration/cma.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
class CmaEsSampler(BaseSampler):
"""A Sampler using cma library as the backend.
Note that parallel execution of trials may degrade the optimization performance of CMA-ES,
especially if the number of trials running in parallel exceeds the population size.
Example:
Optimize a simple quadratic function by using :class:`~optuna.integration.CmaEsSampler`.
Expand All @@ -59,12 +56,14 @@ def objective(trial):
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=100)
Note that parallel execution of trials may affect the optimization performance of CMA-ES,
especially if the number of trials running in parallel exceeds the population size.
Args:
x0:
A dictionary of an initial parameter values for CMA-ES. By default, the mean of ``low``
and ``high`` for each distribution is used. If the distribution is categorical, the
item in the middle of ``choices`` is selected.
and ``high`` for each distribution is used.
Please refer to `cma.CMAEvotionStrategy <http://cma.gforge.inria.fr/apidocs-pycma/cma.e
volution_strategy.CMAEvolutionStrategy.html>`_ for further details of ``x0``.
Expand Down Expand Up @@ -154,10 +153,8 @@ def infer_relative_search_space(self, study, trial):
search_space = {}
for name, distribution in optuna.samplers.product_search_space(study).items():
if distribution.single():
# `cma` cannot handle distributions that contain just a single value,
# so we skip this distribution.
#
# Note that `Trial` takes care of this distribution during suggestion.
# `cma` cannot handle distributions that contain just a single value, so that
# the parameter values for such distributions are sampled by `sample_independent`.
continue

search_space[name] = distribution
Expand Down Expand Up @@ -357,7 +354,7 @@ def ask(self, trials, last_told_trial_number):

# individual_index may exceed the population size due to the parallel execution of multiple
# trials. In such cases, `cma.cma.CMAEvolutionStrategy.ask` is called multiple times in an
# iteration, and that may degrade the optimization performance of CMA-ES.
# iteration, and that may affect the optimization performance of CMA-ES.
# In addition, please note that some trials may suggest the same parameters when multiple
# samplers invoke this method simultaneously.
while individual_index >= popsize:
Expand Down

0 comments on commit 119372d

Please sign in to comment.