Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
williamFalcon committed Aug 3, 2019
1 parent a687a2f commit d90e6b4
Showing 1 changed file with 4 additions and 34 deletions.
38 changes: 4 additions & 34 deletions docs/hyperparameter_optimization/HyperOptArgumentParser.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,57 +146,27 @@ for trial_hparams in hparams.trials(2):
# trial_hparams now has values sampled from the training routine
```

### `optimize_parallel`

`DEPRECATED... see optimize_parallel_gpu / _cpu`

``` {.python}
hparams = parser.parse_args()
hparams.optimize_parallel(function_to_optimize, nb_trials=20, nb_parallel=2)
```

Parallelize the trials across `nb_parallel` processes. Arguments passed
into the `function_to_optimize` are the `trial_params` and index of
process it's in.

**Example**

``` {.python}
# parallelize tuning on 2 gpus
# this will place each trial in n into a given gpu
def opt_function(trial_params, process_index):
GPUs = ['0', '1']
os.environ["CUDA_VISIBLE_DEVICES"] = GPUs[process_index]
train_main(trial_params)
hparams = parser.parse_args()
hparams.optimize_parallel(opt_function, nb_trials=20, nb_parallel=2)
# at the end of the optimize_parallel function, all 20 trials will be completed
# in this case by running 10 sets of 2 trials in parallel
```

### `optimize_parallel_gpu`

``` {.python}
hparams = parser.parse_args()
hparams.optimize_parallel_gpu(function_to_optimize, gpu_ids=['1', '0, 2'], nb_trials=20, nb_workers=2)
hparams.optimize_parallel_gpu(function_to_optimize, gpu_ids=['1', '0, 2'])
```

Parallelize the trials across `nb_workers` processes. Auto assign the
correct gpus. Argument passed into the `function_to_optimize` is the
`trial_params` argument.
`trial_params` argument and the gpu_ids.

**Example**

``` {.python}
# parallelize tuning on 2 gpus
# this will place each trial in n into a given gpu
def train_main(trial_params):
def train_main(trial_params, gpu_ids):
# train your model, etc here...
hparams = parser.parse_args()
hparams.optimize_parallel_gpu(train_main, gpu_ids=['1', '0, 2'], nb_trials=20, nb_workers=2)
hparams.optimize_parallel_gpu(train_main, gpu_ids=['1', '0, 2'])
# at the end of the optimize_parallel function, all 20 trials will be completed
# in this case by running 10 sets of 2 trials in parallel
Expand Down

0 comments on commit d90e6b4

Please sign in to comment.