Refactoring configs (#248)
- make every run be an experiment by default - deprecate `mode` configs - introduce `debug` configs - introduce `log_dir` configs - remove unnecessary utilities from `utils.extras()` - add config flag for skipping training - update README.md
This commit is contained in:
1 parent
2ff8e053bf
commit
19f5454d13
27 files changed
+210
-238
No files matched your search
@@ -18,7 +18,7 @@ early_stopping:
|
||||
|
||||
model_summary:
|
||||
_target_: pytorch_lightning.callbacks.RichModelSummary
|
||||
max_depth: 1
|
||||
max_depth: -1
|
||||
|
||||
rich_progress_bar:
|
||||
_target_: pytorch_lightning.callbacks.RichProgressBar
|
||||
@@ -8,7 +8,7 @@ watch_model:
|
||||
|
||||
upload_code_as_artifact:
|
||||
_target_: src.callbacks.wandb_callbacks.UploadCodeAsArtifact
|
||||
code_dir: ${work_dir}/src
|
||||
code_dir: ${original_work_dir}/src
|
||||
|
||||
upload_ckpts_as_artifact:
|
||||
_target_: src.callbacks.wandb_callbacks.UploadCheckpointsAsArtifact
|
||||
|
||||
+19
-11
@@ -3,23 +3,27 @@
|
||||
# specify here default training configuration
|
||||
defaults:
|
||||
- _self_
|
||||
- trainer: default.yaml
|
||||
- model: mnist.yaml
|
||||
- datamodule: mnist.yaml
|
||||
- model: mnist.yaml
|
||||
- callbacks: default.yaml
|
||||
- logger: null # set logger here or use command line (e.g. `python run.py logger=wandb`)
|
||||
- logger: null # set logger here or use command line (e.g. `python run.py logger=tensorboard`)
|
||||
- trainer: default.yaml
|
||||
|
||||
# modes are special collections of config options for different purposes, e.g. debugging
|
||||
- mode: default.yaml
|
||||
# logging folder path
|
||||
- log_dir: default.yaml
|
||||
|
||||
# experiment configs allow for version control of specific configurations
|
||||
# for example, use them to store best hyperparameters for each combination of model and datamodule
|
||||
# e.g. best hyperparameters for each combination of model and datamodule
|
||||
- experiment: null
|
||||
|
||||
# debugging config (enable through command line, e.g. `python run.py debug=one_epoch)
|
||||
- debug: null
|
||||
|
||||
# config for hyperparameter optimization
|
||||
- hparams_search: null
|
||||
|
||||
# optional local config for machine/user specific settings
|
||||
# it's optional since it doesn't need to exist and is excluded from version control
|
||||
- optional local: default.yaml
|
||||
|
||||
# enable color logging
|
||||
@@ -30,10 +34,10 @@ defaults:
|
||||
# hydra hijacks working directory by changing it to the new log directory
|
||||
# so it's useful to have this path as a special variable
|
||||
# https://hydra.cc/docs/next/tutorials/basic/running_your_app/working_directory
|
||||
work_dir: ${hydra:runtime.cwd}
|
||||
original_work_dir: ${hydra:runtime.cwd}
|
||||
|
||||
# path to folder with data
|
||||
data_dir: ${work_dir}/data/
|
||||
data_dir: ${original_work_dir}/data/
|
||||
|
||||
# pretty print config at the start of the run using Rich library
|
||||
print_config: True
|
||||
@@ -41,12 +45,16 @@ print_config: True
|
||||
# disable python warnings if they annoy you
|
||||
ignore_warnings: True
|
||||
|
||||
# set False to skip model training
|
||||
train: True
|
||||
|
||||
# evaluate on test set, using best model weights achieved during training
|
||||
# lightning chooses best weights based on metric specified in checkpoint callback
|
||||
# lightning chooses best weights based on the metric specified in checkpoint callback
|
||||
test_after_training: True
|
||||
|
||||
# seed for random number generators in pytorch, numpy and python.random
|
||||
seed: null
|
||||
|
||||
# name of the run, should be used along with experiment mode
|
||||
name: null
|
||||
# default name for the experiment, determines logging folder path
|
||||
# (you can overwrite this name in experiment configs)
|
||||
name: "default"
|
||||
@@ -3,5 +3,5 @@ _target_: src.datamodules.mnist_datamodule.MNISTDataModule
|
||||
data_dir: ${data_dir} # data_dir is specified in config.yaml
|
||||
batch_size: 64
|
||||
train_val_test_split: [55_000, 5_000, 10_000]
|
||||
num_workers: 0
|
||||
num_workers: 4
|
||||
pin_memory: False
|
||||
@@ -0,0 +1,27 @@
|
||||
# @package _global_
|
||||
|
||||
# default debugging setup, runs 1 full epoch
|
||||
|
||||
defaults:
|
||||
- override /log_dir: debug.yaml
|
||||
|
||||
trainer:
|
||||
max_epochs: 1
|
||||
gpus: 0 # debuggers don't like gpus
|
||||
detect_anomaly: true
|
||||
track_grad_norm: 2
|
||||
|
||||
datamodule:
|
||||
num_workers: 0 # debuggers don't like multiprocessing
|
||||
pin_memory: False
|
||||
|
||||
# sets level of all command line loggers to 'DEBUG'
|
||||
# https://hydra.cc/docs/tutorials/basic/running_your_app/logging/
|
||||
hydra:
|
||||
verbose: True
|
||||
|
||||
# use this to set level of only chosen command line loggers to 'DEBUG'
|
||||
# verbose: [src.train, src.utils]
|
||||
|
||||
# config is already printed by hydra when `hydra/verbose: True`
|
||||
print_config: False
|
||||
@@ -0,0 +1,12 @@
|
||||
# @package _global_
|
||||
|
||||
# debugs by using only 1% of the data
|
||||
|
||||
defaults:
|
||||
- default.yaml
|
||||
|
||||
trainer:
|
||||
max_epochs: 3
|
||||
limit_train_batches: 0.01
|
||||
limit_val_batches: 0.01
|
||||
limit_test_batches: 0.01
|
||||
@@ -0,0 +1,10 @@
|
||||
# @package _global_
|
||||
|
||||
# overfits to 3 batches
|
||||
|
||||
defaults:
|
||||
- default.yaml
|
||||
|
||||
trainer:
|
||||
max_epochs: 20
|
||||
overfit_batches: 3
|
||||
@@ -0,0 +1,12 @@
|
||||
# @package _global_
|
||||
|
||||
# debugs with execution time profiling
|
||||
|
||||
defaults:
|
||||
- default.yaml
|
||||
|
||||
trainer:
|
||||
max_epochs: 1
|
||||
profiler: "simple"
|
||||
# profiler: "advanced"
|
||||
# profiler: "pytorch"
|
||||
@@ -0,0 +1,9 @@
|
||||
# @package _global_
|
||||
|
||||
# debugs by running 1 train, 1 validation and 1 test step
|
||||
|
||||
defaults:
|
||||
- default.yaml
|
||||
|
||||
trainer:
|
||||
fast_dev_run: true
|
||||
@@ -0,0 +1,9 @@
|
||||
# @package _global_
|
||||
|
||||
# debugs by running only test epoch
|
||||
|
||||
defaults:
|
||||
- default.yaml
|
||||
|
||||
train: False
|
||||
test_after_training: True
|
||||
@@ -4,24 +4,22 @@
|
||||
# python run.py experiment=example
|
||||
|
||||
defaults:
|
||||
- override /mode: exp.yaml
|
||||
- override /trainer: default.yaml
|
||||
- override /model: mnist.yaml
|
||||
- override /datamodule: mnist.yaml
|
||||
- override /model: mnist.yaml
|
||||
- override /callbacks: default.yaml
|
||||
- override /logger: null
|
||||
- override /trainer: default.yaml
|
||||
|
||||
# all parameters below will be merged with parameters from default configurations set above
|
||||
# this allows you to overwrite only specified parameters
|
||||
|
||||
# name of the run determines folder name in logs
|
||||
# can also be accessed by loggers
|
||||
name: "example"
|
||||
name: "simple_dense_net"
|
||||
|
||||
seed: 12345
|
||||
|
||||
trainer:
|
||||
min_epochs: 1
|
||||
min_epochs: 10
|
||||
max_epochs: 10
|
||||
gradient_clip_val: 0.5
|
||||
|
||||
@@ -33,10 +31,7 @@ model:
|
||||
|
||||
datamodule:
|
||||
batch_size: 64
|
||||
train_val_test_split: [55_000, 5_000, 10_000]
|
||||
|
||||
logger:
|
||||
csv:
|
||||
name: csv/${name}
|
||||
wandb:
|
||||
tags: ["mnist", "simple_dense_net"]
|
||||
tags: ["mnist", "${name}"]
|
||||
@@ -0,0 +1,8 @@
|
||||
# @package _global_
|
||||
|
||||
hydra:
|
||||
run:
|
||||
dir: logs/debugs/runs/${name}/${now:%Y-%m-%d}_${now:%H-%M-%S}
|
||||
sweep:
|
||||
dir: logs/debugs/multiruns/${name}/${now:%Y-%m-%d}_${now:%H-%M-%S}
|
||||
subdir: ${hydra.job.num}
|
||||
@@ -0,0 +1,8 @@
|
||||
# @package _global_
|
||||
|
||||
hydra:
|
||||
run:
|
||||
dir: logs/experiments/runs/${name}/${now:%Y-%m-%d}_${now:%H-%M-%S}
|
||||
sweep:
|
||||
dir: logs/experiments/multiruns/${name}/${now:%Y-%m-%d}_${now:%H-%M-%S}
|
||||
subdir: ${hydra.job.num}
|
||||
@@ -4,5 +4,4 @@ csv:
|
||||
_target_: pytorch_lightning.loggers.csv_logs.CSVLogger
|
||||
save_dir: "."
|
||||
name: "csv/"
|
||||
version: ${name}
|
||||
prefix: ""
|
||||
@@ -3,7 +3,7 @@
|
||||
wandb:
|
||||
_target_: pytorch_lightning.loggers.wandb.WandbLogger
|
||||
project: "template-tests"
|
||||
name: ${name}
|
||||
# name: ${name}
|
||||
save_dir: "."
|
||||
offline: False # set True to store all logs only locally
|
||||
id: null # pass correct id to resume experiment!
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
# @package _global_
|
||||
|
||||
# debug mode sets name of the logging folder to 'logs/debug/...'
|
||||
# enables trainer debug options
|
||||
# also sets level od command line logger to DEBUG
|
||||
# example usage:
|
||||
# `python run.py mode=debug`
|
||||
|
||||
defaults:
|
||||
- override /trainer: debug.yaml
|
||||
|
||||
debug_mode: True
|
||||
|
||||
hydra:
|
||||
# sets level of all command line loggers to 'DEBUG'
|
||||
verbose: True
|
||||
|
||||
# https://hydra.cc/docs/tutorials/basic/running_your_app/logging/
|
||||
# use this to set level of only chosen command line loggers to 'DEBUG'
|
||||
# verbose: [src.train, src.utils]
|
||||
|
||||
run:
|
||||
dir: logs/debug/runs/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
||||
sweep:
|
||||
dir: logs/debug/multiruns/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
||||
subdir: ${hydra.job.num}
|
||||
|
||||
# disable rich config printing, since it will be already printed by hydra when `verbose: True`
|
||||
print_config: False
|
||||
@@ -1,13 +0,0 @@
|
||||
# @package _global_
|
||||
|
||||
# default running mode
|
||||
|
||||
default_mode: True
|
||||
|
||||
hydra:
|
||||
# default output paths for all file logs
|
||||
run:
|
||||
dir: logs/runs/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
||||
sweep:
|
||||
dir: logs/multiruns/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
||||
subdir: ${hydra.job.num}
|
||||
@@ -1,17 +0,0 @@
|
||||
# @package _global_
|
||||
|
||||
# experiment mode sets name of the logging folder to the experiment name
|
||||
# can also be used to name the run in the logger
|
||||
# example usage:
|
||||
# `python run.py mode=exp name=some_name`
|
||||
|
||||
experiment_mode: True
|
||||
|
||||
name: ???
|
||||
|
||||
hydra:
|
||||
run:
|
||||
dir: logs/experiments/${name}/runs/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
||||
sweep:
|
||||
dir: logs/experiments/${name}/multiruns/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
||||
subdir: ${hydra.job.num}
|
||||
@@ -3,3 +3,4 @@ defaults:
|
||||
|
||||
gpus: 4
|
||||
strategy: ddp
|
||||
sync_batchnorm: True
|
||||
@@ -1,19 +0,0 @@
|
||||
defaults:
|
||||
- default.yaml
|
||||
|
||||
gpus: 0
|
||||
|
||||
min_epochs: 1
|
||||
max_epochs: 2
|
||||
|
||||
# prints
|
||||
profiler: null
|
||||
|
||||
# debugs
|
||||
fast_dev_run: true
|
||||
overfit_batches: 0
|
||||
limit_train_batches: 1.0
|
||||
limit_val_batches: 1.0
|
||||
limit_test_batches: 1.0
|
||||
track_grad_norm: -1
|
||||
detect_anomaly: true
|
||||
@@ -5,7 +5,7 @@ gpus: 0
|
||||
min_epochs: 1
|
||||
max_epochs: 10
|
||||
|
||||
resume_from_checkpoint: null
|
||||
|
||||
# number of validation steps to execute at the beginning of the training
|
||||
num_sanity_val_steps: 0
|
||||
# num_sanity_val_steps: 0
|
||||
|
||||
resume_from_checkpoint: null
|
||||
Reference in new issue
Block a user