"magic_pdf/git@developer.sourcefind.cn:wangsen/mineru.git" did not exist on "6b7a861e8faa39bcbdd5f8b607930517b468c3bb"
Commit e3c8552f authored by suiguoxin's avatar suiguoxin
Browse files

change qtype format to conforme with BOHB

parent 4feb466c
...@@ -41,11 +41,11 @@ There are 10 types to express your search space as follows: ...@@ -41,11 +41,11 @@ There are 10 types to express your search space as follows:
* `@nni.variable(nni.uniform(low, high),name=variable)` * `@nni.variable(nni.uniform(low, high),name=variable)`
Which means the variable value is a value uniformly between low and high. Which means the variable value is a value uniformly between low and high.
* `@nni.variable(nni.quniform(low, high, q),name=variable)` * `@nni.variable(nni.quniform(low, high, q),name=variable)`
Which means the variable value is a value like randint(floor((high-low)/q)+1)*q + low Which means the variable value is a value like clip(round(uniform(low, high) / q) * q, low, high), where the clip operation is used to constraint the generated value in the bound.
* `@nni.variable(nni.loguniform(low, high),name=variable)` * `@nni.variable(nni.loguniform(low, high),name=variable)`
Which means the variable value is a value drawn according to exp(uniform(low, high)) so that the logarithm of the return value is uniformly distributed. Which means the variable value is a value drawn according to exp(uniform(low, high)) so that the logarithm of the return value is uniformly distributed.
* `@nni.variable(nni.qloguniform(low, high, q),name=variable)` * `@nni.variable(nni.qloguniform(low, high, q),name=variable)`
Which means the variable value is a value like floor((loguniform(low, high) - low) / q) * q + low Which means the variable value is a value like clip(round(loguniform(low, high) / q) * q, low, high), where the clip operation is used to constraint the generated value in the bound.
* `@nni.variable(nni.normal(mu, sigma),name=variable)` * `@nni.variable(nni.normal(mu, sigma),name=variable)`
Which means the variable value is a real value that's normally-distributed with mean mu and standard deviation sigma. Which means the variable value is a real value that's normally-distributed with mean mu and standard deviation sigma.
* `@nni.variable(nni.qnormal(mu, sigma, q),name=variable)` * `@nni.variable(nni.qnormal(mu, sigma, q),name=variable)`
......
...@@ -45,7 +45,7 @@ All types of sampling strategies and their parameter are listed here: ...@@ -45,7 +45,7 @@ All types of sampling strategies and their parameter are listed here:
* When optimizing, this variable is constrained to a two-sided interval. * When optimizing, this variable is constrained to a two-sided interval.
* {"_type":"quniform","_value":[low, high, q]} * {"_type":"quniform","_value":[low, high, q]}
* Which means the variable value is a value like randint(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. * Which means the variable value is a value like clip(round(uniform(low, high) / q) * q, low, high), where the clip operation is used to constraint the generated value in the bound. 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, 5, 10].
* 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]`. * 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]`.
...@@ -54,7 +54,7 @@ All types of sampling strategies and their parameter are listed here: ...@@ -54,7 +54,7 @@ All types of sampling strategies and their parameter are listed here:
* When optimizing, this variable is constrained to be positive. * When optimizing, this variable is constrained to be positive.
* {"_type":"qloguniform","_value":[low, high, q]} * {"_type":"qloguniform","_value":[low, high, q]}
* Which means the variable value is a value like floor((loguniform(low, high) - low) / q) * q + low * Which means the variable value is a value like clip(round(loguniform(low, high)) / q) * q, low, high), where the clip operation is used to constraint the generated value in the bound.
* Suitable for a discrete variable with respect to which the objective is "smooth" and gets smoother with the size of the value, but which should be bounded both above and below. * Suitable for a discrete variable with respect to which the objective is "smooth" and gets smoother with the size of the value, but which should be bounded both above and below.
* {"_type":"normal","_value":[mu, sigma]} * {"_type":"normal","_value":[mu, sigma]}
......
...@@ -57,8 +57,7 @@ def quniform(low, high, q, random_state): ...@@ -57,8 +57,7 @@ def quniform(low, high, q, random_state):
q: sample step q: sample step
random_state: an object of numpy.random.RandomState random_state: an object of numpy.random.RandomState
''' '''
assert high > low, 'Upper bound must be larger than lower bound' return np.clip(np.round(uniform(low, high, random_state) / q) * q, low, high)
return randint(np.floor((high-low)/q)+1, random_state) * q + low
def loguniform(low, high, random_state): def loguniform(low, high, random_state):
...@@ -78,7 +77,7 @@ def qloguniform(low, high, q, random_state): ...@@ -78,7 +77,7 @@ def qloguniform(low, high, q, random_state):
q: sample step q: sample step
random_state: an object of numpy.random.RandomState random_state: an object of numpy.random.RandomState
''' '''
return np.floor((loguniform(low, high, random_state) - low) / q) * q + low return np.clip(np.round(loguniform(low, high, random_state) / q) * q, low, high)
def normal(mu, sigma, random_state): def normal(mu, sigma, random_state):
......
...@@ -57,14 +57,14 @@ if trial_env_vars.NNI_PLATFORM is None: ...@@ -57,14 +57,14 @@ if trial_env_vars.NNI_PLATFORM is None:
def quniform(low, high, q, name=None): def quniform(low, high, q, name=None):
assert high > low, 'Upper bound must be larger than lower bound' assert high > low, 'Upper bound must be larger than lower bound'
return randint(np.floor((high-low)/q)+1) * q + low return np.clip(round(random.uniform(low, high) / q) * q, low, high)
def loguniform(low, high, name=None): def loguniform(low, high, name=None):
assert low > 0, 'Lower bound must be positive' assert low > 0, 'Lower bound must be positive'
return np.exp(random.uniform(np.log(low), np.log(high))) return np.exp(random.uniform(np.log(low), np.log(high)))
def qloguniform(low, high, q, name=None): def qloguniform(low, high, q, name=None):
return np.floor((loguniform(low, high) - low) / q) * q + low return np.clip(round(loguniform(low, high) / q) * q, low, high)
def normal(mu, sigma, name=None): def normal(mu, sigma, name=None):
return random.gauss(mu, sigma) return random.gauss(mu, sigma)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment