Commit 591fa1d7 authored by suiguoxin's avatar suiguoxin
Browse files

update annotation doc; update smartparam sync

parent 9a00a14c
...@@ -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 round(uniform(low, high) / q) * q Which means the variable value is a value like randint(floor((high-low)/q)+1)*q + low
* `@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 round(exp(uniform(low, high)) / q) * q Which means the variable value is a value like floor((loguniform(low, high) - low) / q) * q + low
* `@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)`
......
...@@ -57,6 +57,7 @@ def quniform(low, high, q, random_state): ...@@ -57,6 +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 randint(np.floor((high-low)/q)+1, random_state) * q + low return randint(np.floor((high-low)/q)+1, random_state) * q + low
......
...@@ -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 round(random.uniform(low, high) / q) * q return randint(np.floor((high-low)/q)+1) * q + low
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 round(loguniform(low, high) / q) * q return np.floor((loguniform(low, high) - low) / q) * q + low
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