"git@developer.sourcefind.cn:OpenDAS/torchaudio.git" did not exist on "5ad6d2ef7def3e9d8ddaa35c29f4c498f137d6fc"
Unverified Commit ab640634 authored by Tab Zhang's avatar Tab Zhang Committed by GitHub
Browse files

add description about update_search_space (#2597)

parent 93d9b674
...@@ -7,7 +7,7 @@ NNI provides state-of-the-art tuning algorithm in builtin-tuners. NNI supports t ...@@ -7,7 +7,7 @@ NNI provides state-of-the-art tuning algorithm in builtin-tuners. NNI supports t
If you want to implement your own tuning algorithm, you can implement a customized Tuner, there are three things to do: If you want to implement your own tuning algorithm, you can implement a customized Tuner, there are three things to do:
1. Inherit the base Tuner class 1. Inherit the base Tuner class
1. Implement receive_trial_result and generate_parameter function 1. Implement receive_trial_result, generate_parameter and update_search_space function
1. Configure your customized tuner in experiment YAML config file 1. Configure your customized tuner in experiment YAML config file
Here is an example: Here is an example:
...@@ -22,7 +22,7 @@ class CustomizedTuner(Tuner): ...@@ -22,7 +22,7 @@ class CustomizedTuner(Tuner):
... ...
``` ```
**2. Implement receive_trial_result and generate_parameter function** **2. Implement receive_trial_result, generate_parameter and update_search_space function**
```python ```python
from nni.tuner import Tuner from nni.tuner import Tuner
...@@ -32,22 +32,32 @@ class CustomizedTuner(Tuner): ...@@ -32,22 +32,32 @@ class CustomizedTuner(Tuner):
... ...
def receive_trial_result(self, parameter_id, parameters, value, **kwargs): def receive_trial_result(self, parameter_id, parameters, value, **kwargs):
''' '''
Receive trial's final result. Receive trial's final result.
parameter_id: int parameter_id: int
parameters: object created by 'generate_parameters()' parameters: object created by 'generate_parameters()'
value: final metrics of the trial, including default metric value: final metrics of the trial, including default metric
''' '''
# your code implements here. # your code implements here.
... ...
def generate_parameters(self, parameter_id, **kwargs): def generate_parameters(self, parameter_id, **kwargs):
''' '''
Returns a set of trial (hyper-)parameters, as a serializable object Returns a set of trial (hyper-)parameters, as a serializable object
parameter_id: int parameter_id: int
''' '''
# your code implements here. # your code implements here.
return your_parameters return your_parameters
...
def update_search_space(self, search_space):
'''
Tuners are advised to support updating search space at run-time.
If a tuner can only set search space once before generating first hyper-parameters,
it should explicitly document this behaviour.
search_space: JSON object created by experiment owner
'''
# your code implements here.
... ...
``` ```
......
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