Skip to content

Commit

Permalink
fix smac quniform issue (microsoft#1448)
Browse files Browse the repository at this point in the history
* support quniform in smac with "ordinal" in original smac
  • Loading branch information
suiguoxin committed Aug 12, 2019
1 parent b446cb0 commit 7752f61
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/en_US/Tuner/SmacTuner.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ SMAC Tuner on NNI

[SMAC](https://www.cs.ubc.ca/~hutter/papers/10-TR-SMAC.pdf) is based on Sequential Model-Based Optimization (SMBO). It adapts the most prominent previously used model class (Gaussian stochastic process models) and introduces the model class of random forests to SMBO, in order to handle categorical parameters. The SMAC supported by nni is a wrapper on [the SMAC3 github repo](https://github.com/automl/SMAC3).

Note that SMAC on nni only supports a subset of the types in [search space spec](../Tutorial/SearchSpaceSpec.md), including `choice`, `randint`, `uniform`, `loguniform`, `quniform(q=1)`.
Note that SMAC on nni only supports a subset of the types in [search space spec](../Tutorial/SearchSpaceSpec.md), including `choice`, `randint`, `uniform`, `loguniform`, `quniform`.
2 changes: 1 addition & 1 deletion docs/zh_CN/Tuner/SmacTuner.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

[SMAC](https://www.cs.ubc.ca/~hutter/papers/10-TR-SMAC.pdf) 基于 Sequential Model-Based Optimization (SMBO). 它利用使用过的结果好的模型(高斯随机过程模型),并将随机森林引入到 SMBO 中,来处理分类参数。 NNI 的 SMAC 通过包装 [SMAC3](https://github.com/automl/SMAC3) 来支持。

NNI 中的 SMAC 只支持部分类型的[搜索空间](../Tutorial/SearchSpaceSpec.md),包括`choice`, `randint`, `uniform`, `loguniform`, `quniform(q=1)`
NNI 中的 SMAC 只支持部分类型的[搜索空间](../Tutorial/SearchSpaceSpec.md),包括`choice`, `randint`, `uniform`, `loguniform`, `quniform`
12 changes: 6 additions & 6 deletions src/sdk/pynni/nni/smac_tuner/convert_ss_to_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ def generate_pcs(nni_search_space_content):
key,
json.dumps(search_space[key]['_value']),
json.dumps(search_space[key]['_value'][0])))
elif search_space[key]['_type'] == 'quniform' \
and search_space[key]['_value'][2] == 1:
pcs_fd.write('%s integer [%d, %d] [%d]\n' % (
elif search_space[key]['_type'] == 'quniform':
low, high, q = search_space[key]['_value'][0:3]
vals = np.clip(np.arange(np.round(low/q), np.round(high/q)+1) * q, low, high).tolist()
pcs_fd.write('%s ordinal {%s} [%s]\n' % (
key,
search_space[key]['_value'][0],
search_space[key]['_value'][1],
search_space[key]['_value'][0]))
json.dumps(vals)[1:-1],
json.dumps(vals[0])))
else:
raise RuntimeError('unsupported _type %s' % search_space[key]['_type'])
except:
Expand Down

0 comments on commit 7752f61

Please sign in to comment.