*Advisor targets the scenario that the automl algorithm wants the methods of both tuner and assessor. Advisor is similar to tuner on that it receives trial parameters request, final results, and generate trial parameters. Also, it is similar to assessor on that it receives intermediate results, trial's end state, and could send trial kill command. Note that, if you use Advisor, tuner and assessor are not allowed to be used at the same time.*
*Warning: API is subject to change in future releases.*
So, if user want to implement a customized Advisor, she/he only need to:
Advisor targets the scenario that the automl algorithm wants the methods of both tuner and assessor. Advisor is similar to tuner on that it receives trial parameters request, final results, and generate trial parameters. Also, it is similar to assessor on that it receives intermediate results, trial's end state, and could send trial kill command. Note that, if you use Advisor, tuner and assessor are not allowed to be used at the same time.
1. Define an Advisor inheriting from the MsgDispatcherBase class
If a user want to implement a customized Advisor, she/he only needs to:
1. Implement the methods with prefix `handle_` except `handle_request`
1. Configure your customized Advisor in experiment YAML config file
Here is an example:
**1. Define an Advisor inheriting from the MsgDispatcherBase class.** For example:
**1) Define an Advisor inheriting from the MsgDispatcherBase class**
@@ -20,13 +16,11 @@ class CustomizedAdvisor(MsgDispatcherBase):
...
@@ -20,13 +16,11 @@ class CustomizedAdvisor(MsgDispatcherBase):
...
...
```
```
**2) Implement the methods with prefix `handle_` except `handle_request`**
**2. Implement the methods with prefix `handle_` except `handle_request`**.. You might find [docs](https://nni.readthedocs.io/en/latest/sdk_reference.html#nni.msg_dispatcher_base.MsgDispatcherBase) for `MsgDispatcherBase` helpful.
Please refer to the implementation of Hyperband ([src/sdk/pynni/nni/hyperband_advisor/hyperband_advisor.py](https://github.com/Microsoft/nni/tree/master/src/sdk/pynni/nni/hyperband_advisor/hyperband_advisor.py)) for how to implement the methods.
**3) Configure your customized Advisor in experiment YAML config file**
**3. Configure your customized Advisor in experiment YAML config file.**
Similar to tuner and assessor. NNI needs to locate your customized Advisor class and instantiate the class, so you need to specify the location of the customized Advisor class and pass literal values as parameters to the \_\_init__ constructor.
Similar to tuner and assessor. NNI needs to locate your customized Advisor class and instantiate the class, so you need to specify the location of the customized Advisor class and pass literal values as parameters to the `__init__` constructor.
```yaml
```yaml
advisor:
advisor:
...
@@ -38,3 +32,7 @@ advisor:
...
@@ -38,3 +32,7 @@ advisor:
classArgs:
classArgs:
arg1:value1
arg1:value1
```
```
## Example
Here we provide an [example](../../../examples/tuners/mnist_keras_customized_advisor).