Hyperparameter Tuning
From experiments to group of experiments
name: "SVM"
kind: 'group'
num_trials: 10
param_space:
C: loguniform(0.01, 1000)
kernel: choice(['rbf', 'poly', 'linear'])
gamma: choice(['scale', 'auto'])
degree: range(2, 5)
params:
C: 1.0
metric:
name: val_accuracy
direction: maximize
run:
- examples/scripts/train_svm.py
Configuring the Ray cluster
resources_per_worker:
cpu: 0.25
gpu: 0.5
ray_config:
num_cpus: 4
num_gpus: 1
NOTE: Docker integration and Ray integration are incompatible for the moment. So, Docker is not supported for running groups of experiments.
Pruning unpromising trails
sampler: tpe
pruner: hyperband
Accessing the Trial instance to model a complex parameter space
Sometimes, it may be necessary to access the optuna.Trial object of the current experiment so we can generate a more complex hyperparameter space. To do so, we just need to the following:
from snapper_ml import job, Trial
@job
def main(param1, ..., paramN):
trial = Trial.get_current()
...
If you’re running a single experiment instead of a group, Trial.get_current will raise an exception.