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

Fix some minor issues in tuner/assessor docstring #1691

Merged
merged 1 commit into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 7 additions & 7 deletions src/sdk/pynni/nni/assessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class Assessor(Recoverable):
to tell whether this trial can be early stopped or not.

This is the abstract base class for all assessors.
Early stopping algorithms should derive this class and override :meth:`assess_trial` method,
Early stopping algorithms should inherit this class and override :meth:`assess_trial` method,
which receives intermediate results from trials and give an assessing result.

If :meth:`assess_trial` returns :obj:`AssessResult.Bad` for a trial,
it hints NNI framework that the trial is likely to result in a poor final accuracy,
and therefore should be killed to save resource.

If an accessor want's to get notified when a trial ends, it can also override :meth:`trial_end`.
If an accessor want's to be notified when a trial ends, it can also override :meth:`trial_end`.

To write a new assessor, you can reference :class:`~nni.medianstop_assessor.MedianstopAssessor`'s code as an example.

Expand All @@ -77,7 +77,7 @@ def assess_trial(self, trial_job_id, trial_history):

The NNI framework has little guarantee on ``trial_history``.
This method is not guaranteed to be invoked for each time ``trial_history`` get updated.
It is also possible that a trial's history keeps updateing after receiving a bad result.
It is also possible that a trial's history keeps updating after receiving a bad result.
And if the trial failed and retried, ``trial_history`` may be inconsistent with its previous value.

The only guarantee is that ``trial_history`` is always growing.
Expand All @@ -96,9 +96,9 @@ def assess_trial(self, trial_job_id, trial_history):

Parameters
----------
trial_job_id: str
trial_job_id : str
Unique identifier of the trial.
trial_history: list
trial_history : list
Intermediate results of this trial. The element type is decided by trial code.

Returns
Expand All @@ -114,9 +114,9 @@ def trial_end(self, trial_job_id, success):

Parameters
----------
trial_job_id: str
trial_job_id : str
Unique identifier of the trial.
success: bool
success : bool
True if the trial successfully completed; False if failed or terminated.
"""

Expand Down
20 changes: 10 additions & 10 deletions src/sdk/pynni/nni/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Tuner(Recoverable):
A new trial will run with this configuration.

This is the abstract base class for all tuners.
Tuning algorithms should derive this class and override :meth:`update_search_space`, :meth:`receive_trial_result`,
Tuning algorithms should inherit this class and override :meth:`update_search_space`, :meth:`receive_trial_result`,
as well as :meth:`generate_parameters` or :meth:`generate_multiple_parameters`.

After initializing, NNI will first call :meth:`update_search_space` to tell tuner the feasible region,
Expand Down Expand Up @@ -96,9 +96,9 @@ def generate_parameters(self, parameter_id, **kwargs):

Parameters
----------
parameter_id: int
parameter_id : int
Unique identifier for requested hyper-parameters. This will later be used in :meth:`receive_trial_result`.
**kwargs:
**kwargs
Unstable parameters which should be ignored by normal users.

Returns
Expand Down Expand Up @@ -129,10 +129,10 @@ def generate_multiple_parameters(self, parameter_id_list, **kwargs):

Parameters
----------
parameter_id_list: list of int
parameter_id_list : list of int
Unique identifiers for each set of requested hyper-parameters.
These will later be used in :meth:`receive_trial_result`.
**kwargs:
**kwargs
Unstable parameters which should be ignored by normal users.

Returns
Expand All @@ -159,13 +159,13 @@ def receive_trial_result(self, parameter_id, parameters, value, **kwargs):

Parameters
----------
parameter_id: int
parameter_id : int
Unique identifier of used hyper-parameters, same with :meth:`generate_parameters`.
parameters
Hyper-parameters generated by :meth:`generate_parameters`.
value
Result from trial (the return value of :func:`nni.report_final_result`).
**kwargs:
**kwargs
Unstable parameters which should be ignored by normal users.
"""
raise NotImplementedError('Tuner: receive_trial_result not implemented')
Expand All @@ -186,11 +186,11 @@ def trial_end(self, parameter_id, success, **kwargs):

Parameters
----------
parameter_id: int
parameter_id : int
Unique identifier for hyper-parameters used by this trial.
success: bool
success : bool
True if the trial successfully completed; False if failed or terminated.
**kwargs:
**kwargs
Unstable parameters which should be ignored by normal users.
"""

Expand Down