You could tinker with the cfg
variable (omegaconf.DictConfig
instance) and see how it works.
Compare the contents of cfg
with config/train_cfg.yaml
.
Recommend running the following on the shell script as a tutorial.
You should notice that outputs/
directory is created when the scripts are single-run, and multirun/
directory is created when the scripts are multi-run.
Also, each directory that is created contains .hydra/
directory which has:
- the current user configurations (
.hydra/config.yaml
) for the process - the current hydra configurations (
.hydra/hydra.yaml
) for the process - the current overridden configurations (
.hydra/overrides.yaml
) for the process
The followings are example runs:
python hydra_sample.py
# basic functionalitypython hydra_sample.py -m run.random_seed=0,1,2,3,4
# multirun parameter sweep with-m
flagpython hydra_sample.py -m "run.random_seed=range(0,5)
# multirun sweep with predefined command line hydra syntaxpython hydra_sample.py +new_variable=0
# Inserting new config values (you could also add predefined config_groups that was not included in the main config)python hydra_sample.py -m +new_variable=0,1,2,3,4
# Insert new config & sweep
configs that start with hydra
are internal hydra configs that changes the behavior of the runs. They are internally defined so you have to refer to the documents.
Single run examples:
python hydra_sample.py hydra.job.chdir=True
# Change working directory (directory of process) when run. You can change this behavior to be the default by settinghydra.job.chdir: True
in theconfig/train_cfg.yaml
filepython hydra_sample.py hydra.job.chdir=True hydra.run.dir=outputs/custom_directory
# Specifying custom directory by overriding (hidden) hydra configurationpython hydra_sample.py hydra.run.dir=outputs/custom_directory
# Note that this does not change the working directory, but the logging file (hydra_sample.log
) &.hydra/
files are generated in thehydra.run.dir
.
Multirun examples:
python hydra_sample.py -m hydra.job.chdir=True +random_seed=0,1,2,3,4
# Multirun with changing working directorypython hydra_sample.py -m hydra.job.chdir=True hydra.sweep.dir=multirun/custom_directory +random_seed=0,1,2,3,4
# Specifying custom multirun directory by overriding (hidden) hydra configurationpython hydra_sample.py -m hydra.sweep.dir=multirun/custom_directory +random_seed=0,1,2,3,4
# Specifying custom multirun directory to storehydra_sample.log
&.hydra/
, but does not change working direcotrypython hydra_sample.py -m hydra.job.chdir=True hydra.sweep.dir=multirun/custom_directory hydra.sweep.subdir=run_${random_seed} +random_seed=0,1,2,3,4
# Specifying custom multirun directory & subdirpython hydra_sample.py -m hydra.job.chdir=True hydra/launcher=joblib hydra.launcher.n_jobs=2 "+random_seed=range(0,5)"
# Multirun sweep with parallel processes & n_job limit. Need to installhydra-joblib-launcher
first! (pip install hydra-joblib-launcher
)
Debug mode:
python hydra_sample.py hydra.verbose=True
# Run using different logging levels