launch.py 1.05 KB
Newer Older
1
2
3
4
5
6
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

"""
Example showing how to create experiment with Python code.
"""
7
8
9
10
11
12
13
14
15
16
17
18
19

from pathlib import Path

from nni.experiment import Experiment

search_space = {
    "dropout_rate": { "_type": "uniform", "_value": [0.5, 0.9] },
    "conv_size": { "_type": "choice", "_value": [2, 3, 5, 7] },
    "hidden_size": { "_type": "choice", "_value": [124, 512, 1024] },
    "batch_size": { "_type": "choice", "_value": [16, 32] },
    "learning_rate": { "_type": "choice", "_value": [0.0001, 0.001, 0.01, 0.1] }
}

20
21
experiment = Experiment('local')
experiment.config.experiment_name = 'MNIST example'
22
experiment.config.trial_concurrency = 2
23
experiment.config.max_trial_number = 10
24
25
26
experiment.config.search_space = search_space
experiment.config.trial_command = 'python3 mnist.py'
experiment.config.trial_code_directory = Path(__file__).parent
27
28
experiment.config.tuner.name = 'TPE'
experiment.config.tuner.class_args['optimize_mode'] = 'maximize'
29
30
experiment.config.training_service.use_active_gpu = True

31
experiment.run(8080)