A hydra sweeper with configurable overrides for reproducible experiments
Project description
Hydra Experiment Sweeper
hydra is a great library to configure model trainings and numerical
experiments. Via its --multirun
facility, you can launch multiple jobs at a time and
evaluate multiple combinations of settings such as learning rates and seeds easily.
However, the built-in sweepers only accept sweep ranges on the command line, which means
that reproducing a set of experiments for a paper or similar relies on you to remember or
write down the exact invocation of hydra that produced the results in the first place.
hydra-experiment-sweeper
lets you configure experiments via YAML. This way colleagues
and yourself a year from now can re-run the same jobs with exactly the same parameters.
defaults:
- override hydra/sweeper: experiment
hydra:
sweeper:
overrides:
learning_rate: 1e-5,1e-6,1e-7
# Any other overrides such as seeds, model, dataset, etc.
Installation
pip install hydra-experiment-sweeper
How to Use
The sweeper accepts any override syntax that hydra accepts on the command line as well as YAML lists for long values such as seeds or paths.
defaults:
- override hydra/sweeper: experiment
hydra:
sweeper:
max_batch_size: 2
overrides:
model: linreg,svm
learning_rate: range(0.1, 0.3, 0.1)
seed:
- 123
- 42
Running this experiment with python example/train.py --config-name experiment -m
launches the configured jobs.
Experiment invocation and output
$ python example/train.py -m
[2021-10-15 17:57:18,241][HYDRA] ExperimentSweeper(max_batch_size=2, overrides={'model': 'linreg,svm', 'learning_rate': 'range(0.1, 0.3, 0.1)', 'seed': [123, 42]}) sweeping
[2021-10-15 17:57:18,242][HYDRA] Sweep output dir : multirun/2021-10-15/17-57-18
[2021-10-15 17:57:18,796][HYDRA] Launching 2 jobs locally
[2021-10-15 17:57:18,796][HYDRA] #0 : model=linreg learning_rate=0.1 seed=123
model:
model_type: linear_regression
seed: 123
learning_rate: 0.1
[2021-10-15 17:57:18,888][HYDRA] #1 : model=linreg learning_rate=0.1 seed=42
model:
model_type: linear_regression
seed: 42
learning_rate: 0.1
[2021-10-15 17:57:18,982][HYDRA] Launching 2 jobs locally
[2021-10-15 17:57:18,982][HYDRA] #2 : model=linreg learning_rate=0.2 seed=123
model:
model_type: linear_regression
seed: 123
learning_rate: 0.2
[2021-10-15 17:57:19,079][HYDRA] #3 : model=linreg learning_rate=0.2 seed=42
model:
model_type: linear_regression
seed: 42
learning_rate: 0.2
[2021-10-15 17:57:19,171][HYDRA] Launching 2 jobs locally
[2021-10-15 17:57:19,171][HYDRA] #4 : model=svm learning_rate=0.1 seed=123
model:
model_type: support_vector_machine
seed: 123
learning_rate: 0.1
[2021-10-15 17:57:19,290][HYDRA] #5 : model=svm learning_rate=0.1 seed=42
model:
model_type: support_vector_machine
seed: 42
learning_rate: 0.1
[2021-10-15 17:57:19,405][HYDRA] Launching 2 jobs locally
[2021-10-15 17:57:19,405][HYDRA] #6 : model=svm learning_rate=0.2 seed=123
model:
model_type: support_vector_machine
seed: 123
learning_rate: 0.2
[2021-10-15 17:57:19,497][HYDRA] #7 : model=svm learning_rate=0.2 seed=42
model:
model_type: support_vector_machine
seed: 42
learning_rate: 0.2
You can still override parameters on the command line. Let's say you want to run the same
experiment but instead of sweeping over the configured learning rates, you want to try a
different order of magnitude. python example/train.py --config-name experiment -m learning_rate=1e-6,5e-5,1e-5
works just as you would expect with the built-in sweeper and
overwrites the configured override.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hydra-experiment-sweeper-0.1.1.tar.gz
.
File metadata
- Download URL: hydra-experiment-sweeper-0.1.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.26.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 429fb89ff3995a7c453709f792f63666b76310e03c16ef9960130303446813e1 |
|
MD5 | 7383bf8a78b5ab6013625b624ffeb1da |
|
BLAKE2b-256 | fa1720022b8e2ffa6c87c6b9b2ec607aa09712a61844b7a3bf4a107e897b05c6 |
File details
Details for the file hydra_experiment_sweeper-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: hydra_experiment_sweeper-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.26.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdcde2cdfc9b90cb485c9c7f12fd75711ebc41495188e3e4ea316137ede1dc1e |
|
MD5 | e9a2d96c8519b31cd4cc95fc42f7c32c |
|
BLAKE2b-256 | debfe3009898898a83e15aa4f6eabeaf1eed9159c5a52800ba4e352cacd0c646 |