Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update parallel tpe #1373

Merged
merged 72 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
20bf28b
update readme in ga_squad
xuehui1991 Sep 20, 2018
14d8f60
update readme
xuehui1991 Sep 20, 2018
d842121
fix typo
xuehui1991 Sep 20, 2018
0d67525
Update README.md
xuehui1991 Sep 20, 2018
b52854a
Update README.md
xuehui1991 Sep 20, 2018
374491d
Update README.md
xuehui1991 Sep 20, 2018
c805d2a
update readme
xuehui1991 Sep 20, 2018
c825d49
Merge branch 'update_ga_squad' of https://github.com/xuehui1991/nni i…
xuehui1991 Sep 20, 2018
6fdde2c
Merge branch 'master' of https://github.com/Microsoft/nni
xuehui1991 Sep 25, 2018
d41a8b0
Merge branch 'master' of https://github.com/Microsoft/nni
xuehui1991 Sep 25, 2018
cc765b8
Merge branch 'master' into update_ga_squad
xuehui1991 Sep 26, 2018
ef5eba8
Merge branch 'update_ga_squad' of https://github.com/xuehui1991/nni i…
xuehui1991 Sep 26, 2018
8ff4508
Merge branch 'xuehui1991-update_ga_squad'
xuehui1991 Sep 26, 2018
629222f
update tuner docs about Anneal
xuehui1991 Dec 4, 2018
ef74ffa
update
xuehui1991 Dec 4, 2018
22b3add
fix path
xuehui1991 Dec 4, 2018
c97fd11
update reference
xuehui1991 Dec 4, 2018
0afbffd
fix bug in config file
xuehui1991 Dec 5, 2018
7022e6e
Merge remote-tracking branch 'upstream/master'
xuehui1991 Dec 14, 2018
770677c
update nni_arch_overview.png
xuehui1991 Dec 14, 2018
e002331
update
xuehui1991 Dec 14, 2018
d066896
update
xuehui1991 Dec 14, 2018
096f69b
update
xuehui1991 Dec 14, 2018
47218a7
Merge remote-tracking branch 'upstream/master'
xuehui1991 Dec 27, 2018
5b84743
Merge remote-tracking branch 'upstream/master'
xuehui1991 Jan 16, 2019
4d989a6
update home page
xuehui1991 Jan 16, 2019
829ff65
Merge remote-tracking branch 'upstream/master'
xuehui1991 Apr 24, 2019
377ddad
update default value of metis tuner
xuehui1991 Apr 24, 2019
93d5d24
Merge remote-tracking branch 'upstream/master'
xuehui1991 May 21, 2019
4465706
fix broken link in CommunitySharings
xuehui1991 May 22, 2019
47308e1
Merge remote-tracking branch 'upstream/master'
xuehui1991 May 28, 2019
2550f5d
update docs about nested search space
xuehui1991 May 28, 2019
71a93e6
update docs
xuehui1991 May 28, 2019
89e13e4
rename cascding to nested
xuehui1991 May 28, 2019
2c9914d
fix broken link
xuehui1991 May 28, 2019
fb721ab
update
xuehui1991 May 28, 2019
593edb7
update issue link
xuehui1991 May 28, 2019
0d3e6b6
fix typo
xuehui1991 May 28, 2019
31309d0
Merge remote-tracking branch 'upstream/master'
xuehui1991 May 28, 2019
0dd7f42
Merge tag 'v0.8'
xuehui1991 Jun 4, 2019
90dfdde
Merge remote-tracking branch 'upstream/master'
xuehui1991 Jun 17, 2019
be72fa4
Merge remote-tracking branch 'upstream/master'
xuehui1991 Jun 24, 2019
216f1f2
update evaluate parameters from GMM
xuehui1991 Jun 24, 2019
d02fdb6
refine code
xuehui1991 Jun 24, 2019
3089e4e
Merge remote-tracking branch 'upstream/master'
xuehui1991 Jun 25, 2019
62a9354
fix optimized mode bug
xuehui1991 Jun 25, 2019
3e1d927
update import warning
xuehui1991 Jun 25, 2019
3606f14
update warning
xuehui1991 Jun 25, 2019
bd1ab20
update optimized mode
xuehui1991 Jun 25, 2019
d194c1d
Merge remote-tracking branch 'upstream/master'
xuehui1991 Jul 10, 2019
a46f764
Merge remote-tracking branch 'upstream/master'
xuehui1991 Jul 12, 2019
ad986e6
fix parallel_tpe bug and refine
xuehui1991 Jul 12, 2019
b4d5529
fix bug
xuehui1991 Jul 12, 2019
8ab8ce7
fix kwargs bug
xuehui1991 Jul 12, 2019
86c5240
fix bug
xuehui1991 Jul 12, 2019
8450bc9
update the default value of parallel_tpe
xuehui1991 Jul 15, 2019
c6176b3
Merge remote-tracking branch 'upstream/master' into parallel_tpe
xuehui1991 Jul 15, 2019
4b2d802
add docs for parallel-tpe
xuehui1991 Jul 15, 2019
830b2b0
fix config_schema bug
xuehui1991 Jul 15, 2019
6cc1055
update community doc
xuehui1991 Jul 15, 2019
c61d3e9
fix typo
xuehui1991 Jul 15, 2019
204fb45
update doc for parallel_tpe
xuehui1991 Jul 17, 2019
36c761f
fix bug in receive trial result
xuehui1991 Jul 17, 2019
a263571
update by comments
xuehui1991 Jul 17, 2019
1509109
update by comments
xuehui1991 Jul 21, 2019
138eea6
fix self.optimal_y is 0 when mean mode
xuehui1991 Jul 26, 2019
57707e5
Merge remote-tracking branch 'upstream/master' into update_parallel_tpe
xuehui1991 Jul 26, 2019
f198bad
update
xuehui1991 Jul 26, 2019
954bea8
update
xuehui1991 Jul 29, 2019
d001eb9
Merge remote-tracking branch 'upstream/master' into update_parallel_tpe
xuehui1991 Aug 1, 2019
8d87a9a
update rst
xuehui1991 Aug 1, 2019
d8153c2
fix typo | add docstring
xuehui1991 Aug 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
101 changes: 101 additions & 0 deletions docs/en_US/CommunitySharings/ParallelizingTpeSearch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Parallelizing a Sequential Algorithm TPE
xuehui1991 marked this conversation as resolved.
Show resolved Hide resolved

TPE approaches were actually run asynchronously in order to make use of multiple compute nodes and to avoid wasting time waiting for trial evaluations to complete. For the TPE approach, the so-called constant liar approach was used: each time a candidate point x∗ was proposed, a fake fitness evaluation of the y was assigned temporarily, until the evaluation completed and reported the actual loss f(x∗).

## Introducion and Problems

### Sequential Model-based Global Optimization

Sequential Model-Based Global Optimization (SMBO) algorithms have been used in many applications where evaluation of the fitness function is expensive. In an application where the true fitness function f: X → R is costly to evaluate, model-based algorithms approximate f with a surrogate that is cheaper to evaluate. Typically the inner loop in an SMBO algorithm is the numerical optimization of this surrogate, or some transformation of the surrogate. The point x∗ that maximizes the surrogate (or its transformation) becomes the proposal for where the true function f should be evaluated. This active-learning-like algorithm template is summarized in the figure below. SMBO algorithms differ in what criterion they optimize to obtain x∗ given a model (or surrogate) of f, and in they model f via observation history H.

![](../../img/parallel_tpe_search4.PNG)

The algorithms in this work optimize the criterion of Expected Improvement (EI). Other criteria have been suggested, such as Probability of Improvement and Expected Improvement, minimizing the Conditional Entropy of the Minimizer, and the bandit-based criterion. We chose to use the EI criterion in TPE because it is intuitive, and has been shown to work well in a variety of settings. Expected improvement is the expectation under some model M of f : X → RN that f(x) will exceed (negatively) some threshold y∗:

![](../../img/parallel_tpe_search_ei.PNG)

Since calculation of p(y|x) is expensive, TPE approach modeled p(y|x) by p(x|y) and p(y).The TPE defines p(x|y) using two such densities:

![](../../img/parallel_tpe_search_tpe.PNG)

where l(x) is the density formed by using the observations {x(i)} such that corresponding loss
f(x(i)) was less than y∗ and g(x) is the density formed by using the remaining observations. TPE algorithm depends on a y∗ that is larger than the best observed f(x) so that some points can be used to form l(x). The TPE algorithm chooses y∗ to be some quantile γ of the observed y values, so that p(y<`y∗`) = γ, but no specific model for p(y) is necessary. The tree-structured form of l and g makes it easy to draw manycandidates according to l and evaluate them according to g(x)/l(x). On each iteration, the algorithm returns the candidate x∗ with the greatest EI.

Here is a simulation of the TPE algorithm in a two-dimensional search space. The difference of background color represents different values. It can be seen that TPE combines exploration and exploitation very well. (Black indicates the points of this round samples, and yellow indicates the points has been taken in the history.)

![](../../img/parallel_tpe_search1.gif)

**Since EI is a continuous function, the highest x of EI is determined at a certain status.** As shown in the figure below, the blue triangle is the point that is most likely to be sampled in this state.

![](../../img/parallel_tpe_search_ei2.PNG)

TPE performs well when we use it in sequential, but if we provide a larger concurrency, then **there will be a large number of points produced in the same EI state**, too concentrated points will reduce the exploration ability of the tuner, resulting in resources waste.

Here is the simulation figure when we set `concurrency=60`, It can be seen that this phenomenon is obvious.

![](../../img/parallel_tpe_search2.gif)

## Research solution

### Approximated q-EI Maximization

The multi-points criterion that we have presented below can potentially be used to deliver an additional design of experiments in one step through the resolution of the optimization problem.

![](../../img/parallel_tpe_search_qEI.PNG)

However, the computation of q-EI becomes intensive as q increases. After our research, there are four popular greedy strategies that approach the result of problem while avoiding its numerical cost.

#### Solution 1: Believing the OK Predictor: The KB(Kriging Believer) Heuristic Strategy

The Kriging Believer strategy replaces the conditional knowledge about the responses at the sites chosen within the last iterations by deterministic values equal to the expectation of the Kriging predictor. Keeping the same notations as previously, the strategy can be summed up as follows:

![](../../img/parallel_tpe_search_kb.PNG)

This sequential strategy delivers a q-points design and is computationally affordable since it relies on the analytically known EI, optimized in d dimensions. However, there is a risk of failure, since believing an OK predictor that overshoots the observed data may lead to a sequence that gets trapped in a non-optimal region for many iterations. We now propose a second strategy that reduces this risk.

#### Solution 2: The CL(Constant Liar) Heuristic Strategy

Let us now consider a sequential strategy in which the metamodel is updated (still without hyperparameter re-estimation) at each iteration with a value L exogenously fixed by the user, here called a ”lie”. The strategy referred to as the Constant Liar consists in lying with the same value L at every iteration: maximize EI (i.e. find xn+1), actualize the model as if y(xn+1) = L, and so on always with the same L ∈ R:

![](../../img/parallel_tpe_search_cl.PNG)

L should logically be determined on the basis of the values taken by y at X. Three values, min{Y}, mean{Y}, and max{Y} are considered here. **The larger L is, the more explorative the algorithm will be, and vice versa.**

We have simulated the method above. The following figure shows the result of using mean value liars to maximize q-EI. We find that the points we have taken have begun to be scattered.

![](../../img/parallel_tpe_search3.gif)

## Experiment

### Branin-Hoo

The four optimization strtigeies presented in the last section are now complared on the Branin-Hoo function which is a classical test-case in global optimization.

![](../../img/parallel_tpe_search_branin.PNG)

The recommended values of a, b, c, r, s and t are: a = 1, b = 5.1 ⁄ (4π2), c = 5 ⁄ π, r = 6, s = 10 and t = 1 ⁄ (8π). This function has three global minimizers(-3.14, 12.27), (3.14, 2.27), (9.42, 2.47).

Next is the comparaison of the q-EI associated with the q first points (q ∈ [1,10]) given by the constant liar strategies (min and max), 2000 q-points designs uniformly drawn for every q, and 2000 q-points LHS designs taken at random for every q.

![](../../img/parallel_tpe_search_result.PNG)

As we can seen on figure, CL[max] and CL[min] offer very good q-EI results compared to random designs, especially for small values of q.

### Gaussian Mixed Model function

We also compared the case of using parallel optimization and not using parallel optimization. A two-dimensional multimodal Gaussian Mixed distribution is used to simulate, the following is our result:

||concurrency=80|concurrency=60|concurrency=40|concurrency=20|concurrency=10|
|---|---|---|---|---|---|
|Without parallel optimization|avg = 0.4841 <br> var = 0.1953|avg = 0.5155 <br> var = 0.2219|avg = 0.5773 <br> var = 0.2570|avg = 0.4680 <br> var = 0.1994| avg = 0.2774 <br> var = 0.1217|
|With parallel optimization|avg = 0.2132 <br> var = 0.0700|avg = 0.2177<br>var = 0.0796| avg = 0.1835 <br> var = 0.0533|avg = 0.1671 <br> var = 0.0413|avg = 0.1918 <br> var = 0.0697|

Note: The total number of samples per test is 240 (ensure that the budget is equal). The trials in each form were repeated 1000 times, the value is the average and variance of the best results in 1000 trials.

## References

[1] James Bergstra, Remi Bardenet, Yoshua Bengio, Balazs Kegl. "Algorithms for Hyper-Parameter Optimization". [Link](https://papers.nips.cc/paper/4443-algorithms-for-hyper-parameter-optimization.pdf)

[2] Meng-Hiot Lim, Yew-Soon Ong. "Computational Intelligence in Expensive Optimization Problems". [Link](https://link.springer.com/content/pdf/10.1007%2F978-3-642-10701-6.pdf)

[3] M. Jordan, J. Kleinberg, B. Scho¨lkopf. "Pattern Recognition and Machine Learning". [Link](http://users.isr.ist.utl.pt/~wurmd/Livros/school/Bishop%20-%20Pattern%20Recognition%20And%20Machine%20Learning%20-%20Springer%20%202006.pdf)
1 change: 1 addition & 0 deletions docs/en_US/CommunitySharings/community_sharings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ In addtion to the official tutorilas and examples, we encourage community contri
NNI in Recommenders <RecommendersSvd>
Neural Architecture Search Comparison <NasComparision>
Hyper-parameter Tuning Algorithm Comparsion <HpoComparision>
Parallelizing Optimization for TPE <ParallelizingTpeSearch>
2 changes: 2 additions & 0 deletions docs/en_US/Tuner/BuiltinTuner.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ TPE, as a black-box optimization, can be used in various scenarios and shows goo

* **optimize_mode** (*maximize or minimize, optional, default = maximize*) - If 'maximize', the tuner will target to maximize metrics. If 'minimize', the tuner will target to minimize metrics.

Note: We have optimized the parallelism of TPE for large-scale trial-concurrency. For the principle of optimization or turn-on optimization, please refer to [TPE document](HyperoptTuner.md).

**Usage example:**

```yaml
Expand Down
25 changes: 24 additions & 1 deletion docs/en_US/Tuner/HyperoptTuner.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,33 @@ TPE, Random Search, Anneal Tuners on NNI

The Tree-structured Parzen Estimator (TPE) is a sequential model-based optimization (SMBO) approach. SMBO methods sequentially construct models to approximate the performance of hyperparameters based on historical measurements, and then subsequently choose new hyperparameters to test based on this model. The TPE approach models P(x|y) and P(y) where x represents hyperparameters and y the associated evaluate matric. P(x|y) is modeled by transforming the generative process of hyperparameters, replacing the distributions of the configuration prior with non-parametric densities. This optimization approach is described in detail in [Algorithms for Hyper-Parameter Optimization](https://papers.nips.cc/paper/4443-algorithms-for-hyper-parameter-optimization.pdf). ​

### Parallel TPE optimization

TPE approaches were actually run asynchronously in order to make use of multiple compute nodes and to avoid wasting time waiting for trial evaluations to complete. The original intention of the algorithm design is to optimize sequential. When we use TPE with a large concurrency, its performance will be bad. We have optimized this phenomenon using Constant Liar algorithm. For the principle of optimization, please refer to our [research blog](../CommunitySharings/ParallelizingTpeSearch.md).

### Usage

To use TPE, you should add the following spec in your experiment's YAML config file:

```yaml
tuner:
builtinTunerName: TPE
classArgs:
optimize_mode: maximize
parallel_optimize: True
constant_liar_type: min
```

**Requirement of classArg**
* **optimize_mode** (*maximize or minimize, optional, default = maximize*) - If 'maximize', tuners will target to maximize metrics. If 'minimize', tuner will target to minimize metrics.
* **parallel_optimize** (*bool, optional, default = False*) - If True, TPE will use Constant Liar algorithm to optimize parallel hyperparameter tuning. Otherwise, TPE will not discriminate between sequential or parallel situations.
* **constant_liar_type** (*min or max or mean, optional, default = min*) - The type of constant liar to use, will logically be determined on the basis of the values taken by y at X. Corresponding to three values, min{Y}, max{Y}, and mean{Y}.


## Random Search

In [Random Search for Hyper-Parameter Optimization](http://www.jmlr.org/papers/volume13/bergstra12a/bergstra12a.pdf) show that Random Search might be surprisingly simple and effective. We suggests that we could use Random Search as baseline when we have no knowledge about the prior distribution of hyper-parameters.

## Anneal

This simple annealing algorithm begins by sampling from the prior, but tends over time to sample from points closer and closer to the best ones observed. This algorithm is a simple variation on random search that leverages smoothness in the response surface. The annealing rate is not adaptive.
This simple annealing algorithm begins by sampling from the prior, but tends over time to sample from points closer and closer to the best ones observed. This algorithm is a simple variation on random search that leverages smoothness in the response surface. The annealing rate is not adaptive.
Binary file added docs/img/parallel_tpe_search1.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search2.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search3.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search4.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search_branin.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search_cl.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search_ei.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search_ei2.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search_kb.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search_qEI.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search_result.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/parallel_tpe_search_tpe.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 63 additions & 4 deletions src/sdk/pynni/nni/hyperopt_tuner/hyperopt_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,19 @@ class HyperoptTuner(Tuner):
HyperoptTuner is a tuner which using hyperopt algorithm.
"""

def __init__(self, algorithm_name, optimize_mode='minimize'):
def __init__(self, algorithm_name, optimize_mode='minimize',
parallel_optimize=False, constant_liar_type='min'):
"""
Parameters
----------
algorithm_name : str
algorithm_name includes "tpe", "random_search" and anneal".
optimize_mode : str
parallel_optimize : bool
More detail could reference: docs/en_US/Tuner/HyperoptTuner.md
xuehui1991 marked this conversation as resolved.
Show resolved Hide resolved
constant_liar_type : str
constant_liar_type including "min", "max" and "mean"
More detail could reference: docs/en_US/Tuner/HyperoptTuner.md
xuehui1991 marked this conversation as resolved.
Show resolved Hide resolved
"""
self.algorithm_name = algorithm_name
self.optimize_mode = OptimizeMode(optimize_mode)
Expand All @@ -205,6 +211,13 @@ def __init__(self, algorithm_name, optimize_mode='minimize'):
self.rval = None
self.supplement_data_num = 0

self.parallel = parallel_optimize
if self.parallel:
self.CL_rval = None
self.constant_liar_type = constant_liar_type
self.running_data = []
self.optimal_y = None

def _choose_tuner(self, algorithm_name):
"""
Parameters
Expand Down Expand Up @@ -266,6 +279,10 @@ def generate_parameters(self, parameter_id, **kwargs):
# but it can cause deplicate parameter rarely
total_params = self.get_suggestion(random_search=True)
self.total_data[parameter_id] = total_params

if self.parallel:
self.running_data.append(parameter_id)

params = split_index(total_params)
return params

Expand All @@ -287,10 +304,39 @@ def receive_trial_result(self, parameter_id, parameters, value, **kwargs):
raise RuntimeError('Received parameter_id not in total_data.')
params = self.total_data[parameter_id]

# code for parallel
if self.parallel:
constant_liar = kwargs.get('constant_liar', False)

if constant_liar:
rval = self.CL_rval
else:
rval = self.rval
self.running_data.remove(parameter_id)

# update the reward of optimal_y
if self.optimal_y is None:
if self.constant_liar_type == 'mean':
self.optimal_y = [reward, 1]
else:
self.optimal_y = reward
else:
if self.constant_liar_type == 'mean':
_sum = self.optimal_y[0] + reward
_number = self.optimal_y[1] + 1
self.optimal_y = [_sum, _number]
elif self.constant_liar_type == 'min':
self.optimal_y = min(self.optimal_y, reward)
elif self.constant_liar_type == 'max':
self.optimal_y = max(self.optimal_y, reward)
logger.debug("Update optimal_y with reward, optimal_y = %s", self.optimal_y)
else:
rval = self.rval


if self.optimize_mode is OptimizeMode.Maximize:
reward = -reward

rval = self.rval
domain = rval.domain
trials = rval.trials

Expand Down Expand Up @@ -375,13 +421,26 @@ def get_suggestion(self, random_search=False):
total_params : dict
parameter suggestion
"""
if self.parallel and len(self.total_data)>20 and len(self.running_data) and self.optimal_y is not None:
self.CL_rval = copy.deepcopy(self.rval)
if self.constant_liar_type == 'mean':
_constant_liar_y = self.optimal_y[0] / self.optimal_y[1]
else:
_constant_liar_y = self.optimal_y
for _parameter_id in self.running_data:
self.receive_trial_result(parameter_id=_parameter_id, parameters=None, value=_constant_liar_y, constant_liar=True)
rval = self.CL_rval

rval = self.rval
random_state = np.random.randint(2**31 - 1)
else:
rval = self.rval
random_state = rval.rstate.randint(2**31 - 1)

trials = rval.trials
algorithm = rval.algo
new_ids = rval.trials.new_trial_ids(1)
rval.trials.refresh()
random_state = rval.rstate.randint(2**31 - 1)

if random_search:
new_trials = hp.rand.suggest(new_ids, rval.domain, trials,
random_state)
Expand Down
10 changes: 10 additions & 0 deletions tools/nni_cmd/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ def setPathCheck(key):
Optional('includeIntermediateResults'): setType('includeIntermediateResults', bool),
Optional('gpuNum'): setNumberRange('gpuNum', int, 0, 99999),
},
'TPE': {
'builtinTunerName': 'TPE',
'classArgs': {
Optional('optimize_mode'): setChoice('optimize_mode', 'maximize', 'minimize'),
Optional('parallel_optimize'): setType('parallel_optimize', bool),
Optional('constant_liar_type'): setChoice('constant_liar_type', 'min', 'max', 'mean')
},
Optional('includeIntermediateResults'): setType('includeIntermediateResults', bool),
Optional('gpuNum'): setNumberRange('gpuNum', int, 0, 99999),
},
'NetworkMorphism': {
'builtinTunerName': 'NetworkMorphism',
'classArgs': {
Expand Down