Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

fix quniform issue ; change related doc #1378

Merged
merged 7 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/en_US/Tutorial/SearchSpaceSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ All types of sampling strategies and their parameter are listed here:
* When optimizing, this variable is constrained to a two-sided interval.

* {"_type":"quniform","_value":[low, high, q]}
* Which means the variable value is a value like round(uniform(low, high) / q) * q
* Which means the variable value is a value like randint(np.floor((high-low)/q)+1)*q + low. For example, for _value specified as [0, 10, 2.5], possible values are [0, 2.5, 5.0, 7.5, 10.0]; For _value specified as [2, 10, 5], possible values are [2, 7]. All possible values have the same possibility to be selected.
xuehui1991 marked this conversation as resolved.
Show resolved Hide resolved

* Suitable for a discrete value with respect to which the objective is still somewhat "smooth", but which should be bounded both above and below. If you want to uniformly choose integer from a range [low, high], you can write `_value` like this: `[low, high, 1]`.

* {"_type":"loguniform","_value":[low, high]}
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/pynni/nni/parameter_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def quniform(low, high, q, random_state):
q: sample step
random_state: an object of numpy.random.RandomState
xuehui1991 marked this conversation as resolved.
Show resolved Hide resolved
'''
return np.round(uniform(low, high, random_state) / q) * q
return randint(np.floor((high-low)/q)+1, random_state) * q + low


def loguniform(low, high, random_state):
Expand Down