Release/1.2 (#198)
* update template to pytorch 1.10+ and lightning 1.5+ * add experiment mode to all experiment configs and implement special logging paths for experiment mode * add `MaxMetric` to model, for computation of best so far validation accuracy * add RichProgressBar to default callbacks * get rid of trick for preventing auto hparam logging, since lightning now supports it with `self.save_hyperparameters(logger=False)` * add `self.save_hyperparameters()` to datamodule since lightinng now supports it * deprecate Apex support * deprecate bash script for conda setup * change `terminate_on_nan` debug option to `detect_anomaly` for compatibility with lightning v1.5 * specify model and datamodule during `trainer.test()`, for compatibility with lightning v1.5 * remove `configs/trainer/all_params.yaml` * make hyperparameter optimization compatible with lightning v1.5 * general documentation improvements
This commit is contained in:
1 parent
6159c413f2
commit
9468ef91c5
29 files changed
+278
-330
No files matched your search
@@ -1,7 +1,7 @@
|
||||
model_checkpoint:
|
||||
_target_: pytorch_lightning.callbacks.ModelCheckpoint
|
||||
monitor: "val/acc" # name of the logged metric which determines when model is improving
|
||||
mode: "max" # can be "max" or "min"
|
||||
mode: "max" # "max" means higher metric value is better, can be also "min"
|
||||
save_top_k: 1 # save k best models (determined by above metric)
|
||||
save_last: True # additionaly always save model from last epoch
|
||||
verbose: False
|
||||
@@ -12,6 +12,9 @@ model_checkpoint:
|
||||
early_stopping:
|
||||
_target_: pytorch_lightning.callbacks.EarlyStopping
|
||||
monitor: "val/acc" # name of the logged metric which determines when model is improving
|
||||
mode: "max" # can be "max" or "min"
|
||||
mode: "max" # "max" means higher metric value is better, can be also "min"
|
||||
patience: 100 # how many validation epochs of not improving until training stops
|
||||
min_delta: 0 # minimum change in the monitored metric needed to qualify as an improvement
|
||||
|
||||
rich_progress_bar:
|
||||
_target_: pytorch_lightning.callbacks.RichProgressBar
|
||||
+4
-3
@@ -33,12 +33,13 @@ print_config: True
|
||||
# disable python warnings if they annoy you
|
||||
ignore_warnings: True
|
||||
|
||||
# check performance on test set, using the best model achieved during training
|
||||
# lightning chooses best model based on metric specified in checkpoint callback
|
||||
# evaluate on test set, using best model weights achieved during training
|
||||
# lightning chooses best weights based on 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, accessed by loggers
|
||||
# name of the run is accessed by loggers
|
||||
# should be used along with experiment mode
|
||||
name: null
|
||||
@@ -4,7 +4,8 @@
|
||||
# python run.py experiment=example_full.yaml
|
||||
|
||||
defaults:
|
||||
- override /trainer: null # override trainer to null so it's not loaded from main config defaults...
|
||||
- override /mode: exp.yaml
|
||||
- override /trainer: null
|
||||
- override /model: null
|
||||
- override /datamodule: null
|
||||
- override /callbacks: null
|
||||
@@ -14,6 +15,10 @@ defaults:
|
||||
# instead we define all modules and their paths directly in this config,
|
||||
# so everything is stored in one place
|
||||
|
||||
# name of the run determines folder name in logs
|
||||
# it's also accessed by loggers
|
||||
name: "example_full"
|
||||
|
||||
seed: 12345
|
||||
|
||||
trainer:
|
||||
@@ -23,18 +28,18 @@ trainer:
|
||||
max_epochs: 10
|
||||
gradient_clip_val: 0.5
|
||||
accumulate_grad_batches: 2
|
||||
weights_summary: null
|
||||
# resume_from_checkpoint: ${work_dir}/last.ckpt
|
||||
weights_summary: "full"
|
||||
num_sanity_val_steps: 0
|
||||
|
||||
model:
|
||||
_target_: src.models.mnist_model.MNISTLitModel
|
||||
lr: 0.001
|
||||
weight_decay: 0.00005
|
||||
input_size: 784
|
||||
lin1_size: 256
|
||||
lin2_size: 256
|
||||
lin3_size: 128
|
||||
output_size: 10
|
||||
lr: 0.001
|
||||
weight_decay: 0.0005
|
||||
|
||||
datamodule:
|
||||
_target_: src.datamodules.mnist_datamodule.MNISTDataModule
|
||||
@@ -48,22 +53,24 @@ callbacks:
|
||||
model_checkpoint:
|
||||
_target_: pytorch_lightning.callbacks.ModelCheckpoint
|
||||
monitor: "val/acc"
|
||||
save_top_k: 2
|
||||
save_last: True
|
||||
mode: "max"
|
||||
save_top_k: 1
|
||||
save_last: True
|
||||
verbose: False
|
||||
dirpath: "checkpoints/"
|
||||
filename: "sample-mnist-{epoch:02d}"
|
||||
filename: "epoch_{epoch:03d}"
|
||||
auto_insert_metric_name: False
|
||||
early_stopping:
|
||||
_target_: pytorch_lightning.callbacks.EarlyStopping
|
||||
monitor: "val/acc"
|
||||
patience: 10
|
||||
mode: "max"
|
||||
patience: 5
|
||||
min_delta: 0
|
||||
rich_progress_bar:
|
||||
_target_: pytorch_lightning.callbacks.RichProgressBar
|
||||
|
||||
logger:
|
||||
wandb:
|
||||
tags: ["best_model", "uwu"]
|
||||
name: ${name}_${now:%Y-%m-%d_%H-%M-%S}
|
||||
tags: ["best_model", "mnist"]
|
||||
notes: "Description of this model."
|
||||
neptune:
|
||||
tags: ["best_model"]
|
||||
csv_logger:
|
||||
save_dir: "."
|
||||
@@ -4,6 +4,7 @@
|
||||
# python run.py experiment=example_simple.yaml
|
||||
|
||||
defaults:
|
||||
- override /mode: exp.yaml
|
||||
- override /trainer: default.yaml
|
||||
- override /model: mnist_model.yaml
|
||||
- override /datamodule: mnist_datamodule.yaml
|
||||
@@ -13,6 +14,10 @@ defaults:
|
||||
# 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
|
||||
# it's also accessed by loggers
|
||||
name: "example_simple"
|
||||
|
||||
seed: 12345
|
||||
|
||||
trainer:
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
# @package _global_
|
||||
|
||||
# example hyperparameter optimization of some experiment with Optuna:
|
||||
# python run.py -m hparams_search=mnist_optuna experiment=example_simple
|
||||
# python run.py -m hparams_search=mnist_optuna experiment=example_simple hydra.sweeper.n_trials=30
|
||||
|
||||
defaults:
|
||||
- override /hydra/sweeper: optuna
|
||||
|
||||
# choose metric which will be optimized by Optuna
|
||||
optimized_metric: "val/acc"
|
||||
optimized_metric: "val/acc_best"
|
||||
|
||||
hydra:
|
||||
# here we define Optuna hyperparameter search
|
||||
|
||||
@@ -5,5 +5,5 @@ defaults:
|
||||
- csv.yaml
|
||||
# - mlflow.yaml
|
||||
# - neptune.yaml
|
||||
# - tensorboard.yaml
|
||||
- tensorboard.yaml
|
||||
- wandb.yaml
|
||||
@@ -3,7 +3,7 @@
|
||||
tensorboard:
|
||||
_target_: pytorch_lightning.loggers.tensorboard.TensorBoardLogger
|
||||
save_dir: "tensorboard/"
|
||||
name: "default"
|
||||
name: null
|
||||
version: ${name}
|
||||
log_graph: False
|
||||
default_hp_metric: True
|
||||
|
||||
@@ -7,7 +7,7 @@ wandb:
|
||||
save_dir: "."
|
||||
offline: False # set True to store all logs only locally
|
||||
id: null # pass correct id to resume experiment!
|
||||
# entity: "" # set to name of your wandb team or just remove it
|
||||
# entity: "" # set to name of your wandb team
|
||||
log_model: False
|
||||
prefix: ""
|
||||
job_type: "train"
|
||||
|
||||
@@ -13,7 +13,7 @@ hydra:
|
||||
verbose: True
|
||||
|
||||
# https://hydra.cc/docs/tutorials/basic/running_your_app/logging/
|
||||
# sets level of only chosen command line loggers to 'DEBUG'
|
||||
# use this to set level of only chosen command line loggers to 'DEBUG'
|
||||
# verbose: [src.train, src.utils.utils]
|
||||
|
||||
# sets output paths for all file logs to 'logs/debug/'
|
||||
|
||||
@@ -11,7 +11,7 @@ name: ???
|
||||
hydra:
|
||||
# sets output paths for all file logs to `logs/experiment/name'
|
||||
run:
|
||||
dir: logs/experiments/${name}
|
||||
dir: logs/experiments/${name}/${now:%Y-%m-%d_%H-%M-%S}
|
||||
sweep:
|
||||
dir: logs/experiments/${name}
|
||||
dir: logs/experiments/${name}/multirun_${now:%Y-%m-%d_%H-%M-%S}
|
||||
subdir: ${hydra.job.num}
|
||||
@@ -1,50 +0,0 @@
|
||||
_target_: pytorch_lightning.Trainer
|
||||
|
||||
# default values for all trainer parameters
|
||||
checkpoint_callback: True
|
||||
default_root_dir: null
|
||||
gradient_clip_val: 0.0
|
||||
process_position: 0
|
||||
num_nodes: 1
|
||||
num_processes: 1
|
||||
gpus: null
|
||||
auto_select_gpus: False
|
||||
tpu_cores: null
|
||||
log_gpu_memory: null
|
||||
progress_bar_refresh_rate: 1
|
||||
overfit_batches: 0.0
|
||||
track_grad_norm: -1
|
||||
check_val_every_n_epoch: 1
|
||||
fast_dev_run: False
|
||||
accumulate_grad_batches: 1
|
||||
max_epochs: 1
|
||||
min_epochs: 1
|
||||
max_steps: null
|
||||
min_steps: null
|
||||
limit_train_batches: 1.0
|
||||
limit_val_batches: 1.0
|
||||
limit_test_batches: 1.0
|
||||
val_check_interval: 1.0
|
||||
flush_logs_every_n_steps: 100
|
||||
log_every_n_steps: 50
|
||||
accelerator: null
|
||||
sync_batchnorm: False
|
||||
precision: 32
|
||||
weights_summary: "top"
|
||||
weights_save_path: null
|
||||
num_sanity_val_steps: 2
|
||||
truncated_bptt_steps: null
|
||||
resume_from_checkpoint: null
|
||||
profiler: null
|
||||
benchmark: False
|
||||
deterministic: False
|
||||
reload_dataloaders_every_epoch: False
|
||||
auto_lr_find: False
|
||||
replace_sampler_ddp: True
|
||||
terminate_on_nan: False
|
||||
auto_scale_batch_size: False
|
||||
prepare_data_per_node: True
|
||||
plugins: null
|
||||
amp_backend: "native"
|
||||
amp_level: "O2"
|
||||
move_metrics_to_cpu: False
|
||||
@@ -13,10 +13,9 @@ profiler: null
|
||||
|
||||
# debugs
|
||||
fast_dev_run: true
|
||||
num_sanity_val_steps: 2
|
||||
overfit_batches: 0
|
||||
limit_train_batches: 1.0
|
||||
limit_val_batches: 1.0
|
||||
limit_test_batches: 1.0
|
||||
track_grad_norm: -1
|
||||
terminate_on_nan: true
|
||||
detect_anomaly: true
|
||||
@@ -1,11 +1,11 @@
|
||||
_target_: pytorch_lightning.Trainer
|
||||
|
||||
# set `1` to train on GPU, `0` to train on CPU only
|
||||
gpus: 0
|
||||
|
||||
min_epochs: 1
|
||||
max_epochs: 10
|
||||
|
||||
weights_summary: null
|
||||
progress_bar_refresh_rate: 5
|
||||
resume_from_checkpoint: null
|
||||
weights_summary: "full"
|
||||
num_sanity_val_steps: 0
|
||||
Reference in new issue
Block a user