develop more generic version of template, switch to using hydra initializers

This commit is contained in:
hobogalaxy committed 2021-01-19 02:23:13 +01:00
1 parent e93283d890
commit 7fe01e22d3
26 files changed
+329 -512

No files matched your search

@@ -1,17 +1,15 @@
model_checkpoint:
class: pytorch_lightning.callbacks.ModelCheckpoint
args:
monitor: "val_acc" # name of the logged metric which determines when model is improving
save_top_k: 2 # save k best models (determined by above metric)
save_last: True # additionaly always save model from last epoch
mode: "max" # can be "max" or "min"
filepath: "checkpoints/{epoch}"
_target_: pytorch_lightning.callbacks.ModelCheckpoint
monitor: "val_acc" # name of the logged metric which determines when model is improving
save_top_k: 2 # save k best models (determined by above metric)
save_last: True # additionaly always save model from last epoch
mode: "max" # can be "max" or "min"
filepath: "checkpoints/{epoch}"
early_stopping:
class: pytorch_lightning.callbacks.EarlyStopping
args:
monitor: "val_acc" # name of the logged metric which determines when model is improving
patience: 100 # how many epochs of not improving until training stops
mode: "max" # can be "max" or "min"
min_delta: 0.0 # minimum change in the monitored metric needed to qualify as an improvement
_target_: pytorch_lightning.callbacks.EarlyStopping
monitor: "val_acc" # name of the logged metric which determines when model is improving
patience: 100 # how many epochs of not improving until training stops
mode: "max" # can be "max" or "min"
min_delta: 0.0 # minimum change in the monitored metric needed to qualify as an improvement
@@ -4,12 +4,10 @@ defaults:
save_confusion_matrix_to_wandb:
class: src.callbacks.wandb_callbacks.SaveConfusionMatrixToWandb
args:
class_names: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
_target_: src.callbacks.wandb_callbacks.SaveConfusionMatrixToWandb
class_names: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
save_f1_precision_recall_heatmap_to_wandb:
class: src.callbacks.wandb_callbacks.SaveMetricsHeatmapToWandb
args:
class_names: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
_target_: src.callbacks.wandb_callbacks.SaveMetricsHeatmapToWandb
class_names: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
+6 -21
View File
@@ -3,30 +3,15 @@ defaults:
save_best_metric_scores_to_wandb:
class: src.callbacks.wandb_callbacks.SaveBestMetricScoresToWandb
args: {}
_target_: src.callbacks.wandb_callbacks.SaveBestMetricScoresToWandb
upload_code_to_wandb_as_artifact:
class: src.callbacks.wandb_callbacks.SaveCodeToWandb
args:
code_dir: ${work_dir}/
_target_: src.callbacks.wandb_callbacks.SaveCodeToWandb
code_dir: ${original_work_dir}/
upload_ckpts_to_wandb_as_artifact:
class: src.callbacks.wandb_callbacks.UploadAllCheckpointsToWandb
args:
ckpt_dir: "checkpoints/"
upload_best_only: False
#save_confusion_matrix_to_wandb:
# class: src.callbacks.wandb_callbacks.SaveConfusionMatrixToWandb
# args:
# class_names: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
#save_f1_precision_recall_heatmap_to_wandb:
# class: src.callbacks.wandb_callbacks.SaveMetricsHeatmapToWandb
# args:
# class_names: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
_target_: src.callbacks.wandb_callbacks.UploadAllCheckpointsToWandb
ckpt_dir: "checkpoints/"
upload_best_only: False
+4 -15
View File
@@ -5,11 +5,14 @@ defaults:
- trainer: default_trainer.yaml
- model: mnist_model.yaml
- datamodule: mnist_datamodule.yaml
- optimizer: adam.yaml
- seeds: default_seeds.yaml # set this to null if you don't want to use seeds
- callbacks: default_callbacks.yaml # set this to null if you don't want to use callbacks
- logger: null # set logger here or use command line (e.g. `python train.py logger=wandb`)
# we add this just to enable color logging
# - hydra/hydra_logging: colorlog
# - hydra/job_logging: colorlog
# path to original working directory (the directory that `train.py` was executed from in command line)
# hydra hijacks working directory by changing it to the current log directory,
@@ -22,20 +25,6 @@ original_work_dir: ${hydra:runtime.cwd}
data_dir: ${original_work_dir}/data/
# define which things will be saved as hyperparameters by lightning loggers
extra_logs:
save_model_class_path: True
save_optimizer_class_path: True
save_datamodule_class_path: True
save_model_architecture_class_path: True
save_model_args: True
save_datamodule_args: True
save_optimizer_args: True
save_trainer_args: False
save_seeds: True
save_data_train_val_test_sizes: False
# output paths for hydra logs
hydra:
run:
@@ -1,7 +1,6 @@
class: src.datamodules.mnist_datamodule.MNISTDataModule
args:
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: 1
pin_memory: False
_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: 1
pin_memory: False
@@ -1,3 +1,5 @@
# @package _global_
# to execute this experiment run:
# python train.py +experiment=exp_example_advanced
@@ -5,7 +7,6 @@ defaults:
- override /trainer: default_trainer.yaml # choose trainer from 'configs/trainer/' folder
- override /model: mnist_model.yaml # choose model from 'configs/model/' folder
- override /datamodule: mnist_datamodule.yaml # choose datamodule from 'configs/datamodule/' folder
- override /optimizer: adam.yaml # choose optimizer from 'configs/optimizer/' folder
- override /seeds: default_seeds.yaml # choose seeds from 'configs/seeds/' folder
- override /callbacks: default_callbacks.yaml # choose callback set from 'configs/callbacks/' folder
- override /logger: null # choose logger from 'configs/logger/' folder or set it from console when running experiment:
@@ -15,51 +16,41 @@ defaults:
# this allows you to overwrite only specified parameters
seeds:
pytorch_seed: 12345 # pytorch seed for this experiment (affects torch.utils.data.random_split() method used in mnist_datamodule)
pytorch_seed: 12345 # pytorch seed for this experiment (affects torch.utils.data.random_split() method used in mnist_datamodule)
trainer:
args:
min_epochs: 1 # train for at least this many epochs (denies early stopping)
max_epochs: 10 # train for maximum this many epochs
gradient_clip_val: 0.5 # gradient clipping (helps with exploding gradient issues)
accumulate_grad_batches: 2 # perform optimization step after accumulating gradient from 2 batches
fast_dev_run: False # execute 1 training, 1 validation and 1 test epoch only
limit_train_batches: 0.6 # train on 60% of training data
limit_val_batches: 0.9 # validate on 90% of validation data
limit_test_batches: 1.0 # test on 100% of test data
val_check_interval: 0.5 # perform validation twice per epoch
# resume_from_checkpoint: ${work_dir}/last.ckpt # path to checkpoint (this can be also url for download)
min_epochs: 1 # train for at least this many epochs (denies early stopping)
max_epochs: 10 # train for maximum this many epochs
gradient_clip_val: 0.5 # gradient clipping (helps with exploding gradient issues)
accumulate_grad_batches: 2 # perform optimization step after accumulating gradient from 2 batches
fast_dev_run: False # execute 1 training, 1 validation and 1 test epoch only
limit_train_batches: 0.6 # train on 60% of training data
limit_val_batches: 0.9 # validate on 90% of validation data
limit_test_batches: 1.0 # test on 100% of test data
val_check_interval: 0.5 # perform validation twice per epoch
# resume_from_checkpoint: ${work_dir}/last.ckpt # path to checkpoint (this can be also url for download)
model:
args: # you can add here any params you want and then access them in lightning model
input_size: 784 # img size is 1*28*28
output_size: 10 # there are 10 digit classes
lin1_size: 256
lin2_size: 256
lin3_size: 128
model: # you can add here any params you want and then access them in lightning model
lr: 0.001
weight_decay: 0.00001
input_size: 784 # img size is 1*28*28
output_size: 10 # there are 10 digit classes
lin1_size: 256
lin2_size: 256
lin3_size: 128
datamodule:
args: # you can add here any params you want and then access them in lightning datamodule
batch_size: 64
train_val_test_split: [55_000, 5_000, 10_000]
num_workers: 1 # num of processes used for loading data in parallel
pin_memory: False # dataloaders will copy tensors into CUDA pinned memory before returning them
datamodule: # you can add here any params you want and then access them in lightning datamodule
batch_size: 64
train_val_test_split: [55_000, 5_000, 10_000]
num_workers: 1 # num of processes used for loading data in parallel
pin_memory: False # dataloaders will copy tensors into CUDA pinned memory before returning them
optimizer:
args:
lr: 0.001
weight_decay: 0.00001
logger:
# you can add here additional logger arguments specific for this experiment
logger: # you can add here additional logger arguments specific for this experiment
wandb:
args:
tags: ["best_model", "uwu"]
notes: "Description of this model."
group: "mnist"
tags: ["best_model", "uwu"]
notes: "Description of this model."
group: "mnist"
comet:
args:
tags: ["best_model"]
tags: ["best_model"]
csv_logger:
args:
save_dir: "."
save_dir: "."
@@ -1,3 +1,5 @@
# @package _global_
# to execute this experiment run:
# python train.py +experiment=exp_example_simple
@@ -5,11 +7,10 @@ defaults:
- override /trainer: default_trainer.yaml # choose trainer from 'configs/trainer/' folder or set to null
- override /model: mnist_model.yaml # choose model from 'configs/model/' folder or set to null
- override /datamodule: mnist_datamodule.yaml # choose datamodule from 'configs/datamodule/' folder or set to null
- override /optimizer: adam.yaml # choose optimizer from 'configs/optimizer/' folder or set to null
- override /seeds: default_seeds.yaml # choose seeds from 'configs/seeds/' folder or set to null
- override /callbacks: default_callbacks.yaml # choose callback set from 'configs/callbacks/' folder or set to null
- override /logger: null # choose logger from 'configs/logger/' folder or set it from console when running experiment:
# `python train.py +experiment=exp_example_with_paths logger=wandb`
# `python train.py +experiment=exp_example_simple logger=wandb`
# all parameters below will be merged with parameters from default configurations set above
# this allows you to overwrite only specified parameters
@@ -18,21 +19,14 @@ seeds:
pytorch_seed: 12345
trainer:
args:
max_epochs: 10
max_epochs: 10
model:
args:
lin1_size: 128
lin2_size: 256
lin3_size: 64
lr: 0.001
lin1_size: 128
lin2_size: 256
lin3_size: 64
datamodule:
args:
batch_size: 64
train_val_test_split: [55_000, 5_000, 10_000]
optimizer:
args:
lr: 0.001
weight_decay: 0.00001
batch_size: 64
train_val_test_split: [55_000, 5_000, 10_000]
@@ -1,3 +1,5 @@
# @package _global_
# to execute this experiment run:
# python train.py +experiment=exp_example_with_paths
@@ -5,7 +7,6 @@ defaults:
- override /trainer: null # override trainer to null so it's not loaded from main config defaults
- override /model: null # override model to null so it's not loaded from main config defaults
- override /datamodule: null # override datamodel to null so it's not loaded from main config defaults
- override /optimizer: null # override datamodel to null so it's not loaded from main config defaults
- override /seeds: null # override seeds to null so it's not loaded from main config defaults
- override /callbacks: default_callbacks.yaml # choose callback set from 'configs/callbacks/' folder
- override /logger: null # choose logger from 'configs/logger/' folder or set it from console when running experiment:
@@ -18,37 +19,32 @@ seeds:
pytorch_seed: 12345
trainer:
# trainer is always the same class so we don't need to specify class path
args:
min_epochs: 1
max_epochs: 10
gradient_clip_val: 0.5
gpus: 0
_target_: pytorch_lightning.Trainer
min_epochs: 1
max_epochs: 10
gradient_clip_val: 0.5
weights_summary: null
gpus: 0
model:
class: src.models.simple_mnist_classifier.LitModel
args:
optimizer_config: ${optimizer}
architecture: SimpleDenseNet
input_size: 784
lin1_size: 256
dropout1: 0.25
lin2_size: 256
dropout2: 0.25
lin3_size: 128
dropout3: 0.20
output_size: 10
_target_: src.models.mnist_model.LitModelMNIST
optimizer_config: adam
lr: 0.001
weight_decay: 0.00001
architecture: SimpleDenseNet
input_size: 784
lin1_size: 256
dropout1: 0.25
lin2_size: 256
dropout2: 0.25
lin3_size: 128
dropout3: 0.20
output_size: 10
datamodule:
class: src.datamodules.mnist_datamodule.MNISTDataModule
args:
batch_size: 64
train_val_test_split: [55_000, 5_000, 10_000]
num_workers: 1
pin_memory: False
optimizer:
class: torch.optim.Adam
args:
lr: 0.001
weight_decay: 0.00001
_target_: src.datamodules.mnist_datamodule.MNISTDataModule
data_dir: ${data_dir}
batch_size: 64
train_val_test_split: [55_000, 5_000, 10_000]
num_workers: 1
pin_memory: False
+3 -3
View File
@@ -2,6 +2,6 @@
defaults:
- csv_logger.yaml
- wandb.yaml
# - comet.yaml
# - neptune.yaml
# - tensorboard.yaml
- comet.yaml
- neptune.yaml
- tensorboard.yaml
+3 -4
View File
@@ -1,6 +1,5 @@
# Comet logger config
comet:
class: pytorch_lightning.logger.CometLogger
args:
api_key: ???
project_name: "project_template_test"
_target_: pytorch_lightning.logger.CometLogger
api_key: ???
project_name: "project_template_test"
+3 -4
View File
@@ -1,6 +1,5 @@
# Csv logger config
csv_logger:
class: pytorch_lightning.loggers.CSVLogger
args:
save_dir: "."
name: "csv_logger/"
_target_: pytorch_lightning.loggers.CSVLogger
save_dir: "."
name: "csv_logger/"
+2 -3
View File
@@ -1,4 +1,3 @@
# Neptune logger config
comet:
class: pytorch_lightning.logger.NeptuneLogger
args: {}
neptune:
_target_: pytorch_lightning.logger.NeptuneLogger
+1 -2
View File
@@ -1,4 +1,3 @@
# Tensorboard logger config
tensorboard:
class: pytorch_lightning.logger.TensorboardLogger
args: {}
_target_: pytorch_lightning.logger.TensorboardLogger
+6 -7
View File
@@ -1,9 +1,8 @@
# Weights&Biases logger config
wandb:
class: pytorch_lightning.loggers.wandb.WandbLogger
args:
project: "env_tests"
# entity: "team_name" # set to name of your wandb team or just remove it
offline: False # set True to store all logs only locally
job_type: "train"
save_dir: "."
_target_: pytorch_lightning.loggers.wandb.WandbLogger
project: "env_tests"
entity: "" # set to name of your wandb team or just remove it
offline: False # set True to store all logs only locally
job_type: "train"
save_dir: "."
+13 -12
View File
@@ -1,12 +1,13 @@
class: src.models.mnist_model.LitModelMNIST
args:
optimizer_config: ${optimizer}
architecture: SimpleDenseNet
input_size: 784
lin1_size: 256
dropout1: 0.30
lin2_size: 256
dropout2: 0.25
lin3_size: 128
dropout3: 0.20
output_size: 10
_target_: src.models.mnist_model.LitModelMNIST
optimizer: adam
lr: 0.001
weight_decay: 0.000001
architecture: SimpleDenseNet
input_size: 784
lin1_size: 256
dropout1: 0.30
lin2_size: 256
dropout2: 0.25
lin3_size: 128
dropout3: 0.20
output_size: 10
-4
View File
@@ -1,4 +0,0 @@
class: torch.optim.Adam
args:
lr: 0.001
weight_decay: 0.000001
+12 -13
View File
@@ -1,17 +1,16 @@
# trainer args for debugging model
args:
gpus: 0 # set -1 to train on all GPUs abailable, set 0 to train on CPU only
# auto_select_gpus: True
gpus: 0 # set -1 to train on all GPUs abailable, set 0 to train on CPU only
# auto_select_gpus: True
gradient_clip_val: 0.5
gradient_clip_val: 0.5
# fast_dev_run: True # bugged :( (probably wee need to wait for lightning patch)
limit_train_batches: 1.0
limit_val_batches: 1.0
limit_test_batches: 1.0
val_check_interval: 1.0
profiler: "simple" # use profiler to print execution time profiling after training ends
# fast_dev_run: True # bugged :( (probably wee need to wait for lightning patch)
limit_train_batches: 1.0
limit_val_batches: 1.0
limit_test_batches: 1.0
val_check_interval: 1.0
profiler: "simple" # use profiler to print execution time profiling after training ends
progress_bar_refresh_rate: 10
weights_summary: "full"
default_root_dir: "lightning_logs/"
progress_bar_refresh_rate: 10
weights_summary: "full"
default_root_dir: "lightning_logs/"
+8 -12
View File
@@ -1,12 +1,8 @@
# default args passed to Lightning Trainer on every experiment
# they can be combined or overwritten with args set in experiment config
args:
gpus: 0 # set -1 to train on all GPUs available, set 0 to train on CPU only
# auto_select_gpus: True
max_epochs: 10
gradient_clip_val: 0.5
num_sanity_val_steps: 3
progress_bar_refresh_rate: 10
weights_summary: null # null in yaml represents python None value
default_root_dir: "lightning_logs/"
_target_: pytorch_lightning.Trainer
gpus: 0 # set -1 to train on all GPUs available, set 0 to train on CPU only
max_epochs: 10
gradient_clip_val: 0.5
num_sanity_val_steps: 3
progress_bar_refresh_rate: 10
weights_summary: null # null in yaml represents python None value
default_root_dir: "lightning_logs/"