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

docstr/pylint of GP Tuner & CurveFitting Assessor #1692

Merged
merged 13 commits into from
Nov 11, 2019
3 changes: 3 additions & 0 deletions docs/en_US/sdk_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Tuner
.. autoclass:: nni.batch_tuner.batch_tuner.BatchTuner
:members:

.. autoclass:: nni.gp_tuner.gp_tuner.GPTuner
:members:

Assessor
------------------------
.. autoclass:: nni.assessor.Assessor
Expand Down
17 changes: 8 additions & 9 deletions src/sdk/pynni/nni/curvefitting_assessor/curvefitting_assessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class CurvefittingAssessor(Assessor):

Parameters
----------
epoch_num: int
epoch_num : int
The total number of epoch
optimize_mode: str
optimize_mode : str
optimize mode, 'maximize' or 'minimize'
start_step: int
start_step : int
only after receiving start_step number of reported intermediate results
threshold: float
threshold : float
The threshold that we decide to early stop the worse performance curve.
"""
def __init__(self, epoch_num=20, optimize_mode='maximize', start_step=6, threshold=0.95, gap=1):
Expand Down Expand Up @@ -70,9 +70,9 @@ def trial_end(self, trial_job_id, success):

Parameters
----------
trial_job_id: int
trial_job_id : int
trial job id
success: bool
success : bool
True if succssfully finish the experiment, False otherwise
"""
if success:
Expand All @@ -90,9 +90,9 @@ def assess_trial(self, trial_job_id, trial_history):

Parameters
----------
trial_job_id: int
trial_job_id : int
trial job id
trial_history: list
trial_history : list
The history performance matrix of each trial

Returns
Expand All @@ -105,7 +105,6 @@ def assess_trial(self, trial_job_id, trial_history):
Exception
unrecognize exception in curvefitting_assessor
"""
trial_job_id = trial_job_id
xuehui1991 marked this conversation as resolved.
Show resolved Hide resolved
self.trial_history = trial_history
if not self.set_best_performance:
return AssessResult.Good
Expand Down
104 changes: 53 additions & 51 deletions src/sdk/pynni/nni/curvefitting_assessor/curvefunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

"""
A family of functions used by CurvefittingAssessor
"""
import numpy as np

all_models = {}
Expand All @@ -29,10 +31,10 @@ def vap(x, a, b, c):

Parameters
----------
x: int
a: float
b: float
c: float
x : int
a : float
b : float
c : float

Returns
-------
Expand All @@ -50,10 +52,10 @@ def pow3(x, c, a, alpha):

Parameters
----------
x: int
c: float
a: float
alpha: float
x : int
c : float
a : float
alpha : float

Returns
-------
Expand All @@ -71,9 +73,9 @@ def linear(x, a, b):

Parameters
----------
x: int
a: float
b: float
x : int
a : float
b : float

Returns
-------
Expand All @@ -91,9 +93,9 @@ def logx_linear(x, a, b):

Parameters
----------
x: int
a: float
b: float
x : int
a : float
b : float

Returns
-------
Expand All @@ -112,10 +114,10 @@ def dr_hill_zero_background(x, theta, eta, kappa):

Parameters
----------
x: int
theta: float
eta: float
kappa: float
x : int
theta : float
eta : float
kappa : float

Returns
-------
Expand All @@ -133,10 +135,10 @@ def log_power(x, a, b, c):

Parameters
----------
x: int
a: float
b: float
c: float
x : int
a : float
b : float
c : float

Returns
-------
Expand All @@ -154,11 +156,11 @@ def pow4(x, alpha, a, b, c):

Parameters
----------
x: int
alpha: float
a: float
b: float
c: float
x : int
alpha : float
a : float
b : float
c : float

Returns
-------
Expand All @@ -177,11 +179,11 @@ def mmf(x, alpha, beta, kappa, delta):

Parameters
----------
x: int
alpha: float
beta: float
kappa: float
delta: float
x : int
alpha : float
beta : float
kappa : float
delta : float

Returns
-------
Expand All @@ -199,11 +201,11 @@ def exp4(x, c, a, b, alpha):

Parameters
----------
x: int
c: float
a: float
b: float
alpha: float
x : int
c : float
a : float
b : float
alpha : float

Returns
-------
Expand All @@ -221,9 +223,9 @@ def ilog2(x, c, a):

Parameters
----------
x: int
c: float
a: float
x : int
c : float
a : float

Returns
-------
Expand All @@ -242,11 +244,11 @@ def weibull(x, alpha, beta, kappa, delta):

Parameters
----------
x: int
alpha: float
beta: float
kappa: float
delta: float
x : int
alpha : float
beta : float
kappa : float
delta : float

Returns
-------
Expand All @@ -264,11 +266,11 @@ def janoschek(x, a, beta, k, delta):

Parameters
----------
x: int
a: float
beta: float
k: float
delta: float
x : int
a : float
beta : float
k : float
delta : float

Returns
-------
Expand Down
28 changes: 14 additions & 14 deletions src/sdk/pynni/nni/curvefitting_assessor/model_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CurveModel:

Parameters
----------
target_pos: int
target_pos : int
The point we need to predict
"""
def __init__(self, target_pos):
Expand Down Expand Up @@ -120,14 +120,14 @@ def predict_y(self, model, pos):

Parameters
----------
model: string
model : string
name of the curve function model
pos: int
pos : int
the epoch number of the position you want to predict

Returns
-------
int:
int
The expected matrix at pos
"""
if model_para_num[model] == 2:
Expand All @@ -143,9 +143,9 @@ def f_comb(self, pos, sample):

Parameters
----------
pos: int
pos : int
the epoch number of the position you want to predict
sample: list
sample : list
sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk}

Returns
Expand All @@ -165,7 +165,7 @@ def normalize_weight(self, samples):

Parameters
----------
samples: list
samples : list
a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix,
representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}}

Expand All @@ -187,7 +187,7 @@ def sigma_sq(self, sample):

Parameters
----------
sample: list
sample : list
sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk}

Returns
Expand All @@ -206,9 +206,9 @@ def normal_distribution(self, pos, sample):

Parameters
----------
pos: int
pos : int
the epoch number of the position you want to predict
sample: list
sample : list
sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk}

Returns
Expand All @@ -225,7 +225,7 @@ def likelihood(self, samples):

Parameters
----------
sample: list
sample : list
sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk}

Returns
Expand All @@ -244,7 +244,7 @@ def prior(self, samples):

Parameters
----------
samples: list
samples : list
a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix,
representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}}

Expand All @@ -267,7 +267,7 @@ def target_distribution(self, samples):

Parameters
----------
samples: list
samples : list
a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix,
representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}}

Expand Down Expand Up @@ -322,7 +322,7 @@ def predict(self, trial_history):

Parameters
----------
trial_history: list
trial_history : list
The history performance matrix of each trial.

Returns
Expand Down
Loading