Skip to content

Commit

Permalink
Switch from SGD optimizer to AdamW for patch classification tasks (
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaenzig authored Oct 18, 2024
1 parent fb4f788 commit c6af930
Show file tree
Hide file tree
Showing 18 changed files with 366 additions and 397 deletions.
6 changes: 2 additions & 4 deletions configs/core/tests/offline/embeddings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ model:
out_features: &NUM_CLASSES 2
criterion: torch.nn.CrossEntropyLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: ${oc.env:LR_VALUE, 0.1}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down
6 changes: 2 additions & 4 deletions configs/vision/pathology/offline/classification/bach.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ model:
out_features: &NUM_CLASSES 4
criterion: torch.nn.CrossEntropyLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: &LR_VALUE ${oc.env:LR_VALUE, 0.000625}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trainer:
filename: best
save_last: true
save_top_k: 1
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryAccuracy}
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryBalancedAccuracy}
mode: &MONITOR_METRIC_MODE ${oc.env:MONITOR_METRIC_MODE, max}
- class_path: lightning.pytorch.callbacks.EarlyStopping
init_args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trainer:
filename: best
save_last: true
save_top_k: 1
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryAccuracy}
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryBalancedAccuracy}
mode: &MONITOR_METRIC_MODE ${oc.env:MONITOR_METRIC_MODE, max}
- class_path: lightning.pytorch.callbacks.EarlyStopping
init_args:
Expand Down
8 changes: 3 additions & 5 deletions configs/vision/pathology/offline/classification/crc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ model:
out_features: &NUM_CLASSES 9
criterion: torch.nn.CrossEntropyLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: &LR_VALUE ${oc.env:LR_VALUE, 0.01}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down Expand Up @@ -104,7 +102,7 @@ data:
split: val
dataloaders:
train:
batch_size: &BATCH_SIZE ${oc.env:BATCH_SIZE, 4096}
batch_size: &BATCH_SIZE ${oc.env:BATCH_SIZE, 256}
num_workers: &N_DATA_WORKERS ${oc.env:N_DATA_WORKERS, 4}
shuffle: true
val:
Expand Down
10 changes: 4 additions & 6 deletions configs/vision/pathology/offline/classification/mhist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ trainer:
filename: best
save_last: true
save_top_k: 1
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryAccuracy}
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryBalancedAccuracy}
mode: &MONITOR_METRIC_MODE ${oc.env:MONITOR_METRIC_MODE, max}
- class_path: lightning.pytorch.callbacks.EarlyStopping
init_args:
min_delta: 0
patience: 51
patience: 70
monitor: *MONITOR_METRIC
mode: *MONITOR_METRIC_MODE
- class_path: eva.callbacks.ClassificationEmbeddingsWriter
Expand Down Expand Up @@ -53,11 +53,9 @@ model:
out_features: 1
criterion: torch.nn.BCEWithLogitsLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: &LR_VALUE ${oc.env:LR_VALUE, 0.000625}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trainer:
filename: best
save_last: true
save_top_k: 1
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryAccuracy}
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryBalancedAccuracy}
mode: &MONITOR_METRIC_MODE ${oc.env:MONITOR_METRIC_MODE, max}
- class_path: lightning.pytorch.callbacks.EarlyStopping
init_args:
Expand Down Expand Up @@ -54,11 +54,9 @@ model:
out_features: 1
criterion: torch.nn.BCEWithLogitsLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: &LR_VALUE ${oc.env:LR_VALUE, 0.01}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down Expand Up @@ -118,7 +116,7 @@ data:
split: test
dataloaders:
train:
batch_size: &BATCH_SIZE ${oc.env:BATCH_SIZE, 4096}
batch_size: &BATCH_SIZE ${oc.env:BATCH_SIZE, 256}
num_workers: &N_DATA_WORKERS ${oc.env:N_DATA_WORKERS, 4}
shuffle: true
val:
Expand Down
6 changes: 2 additions & 4 deletions configs/vision/pathology/online/classification/bach.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ model:
out_features: &NUM_CLASSES 4
criterion: torch.nn.CrossEntropyLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: &LR_VALUE ${oc.env:LR_VALUE, 0.000625}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down
8 changes: 3 additions & 5 deletions configs/vision/pathology/online/classification/crc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ model:
out_features: &NUM_CLASSES 9
criterion: torch.nn.CrossEntropyLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: &LR_VALUE ${oc.env:LR_VALUE, 0.01}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down Expand Up @@ -86,7 +84,7 @@ data:
split: val
dataloaders:
train:
batch_size: &BATCH_SIZE ${oc.env:BATCH_SIZE, 4096}
batch_size: &BATCH_SIZE ${oc.env:BATCH_SIZE, 256}
num_workers: &N_DATA_WORKERS ${oc.env:N_DATA_WORKERS, 4}
shuffle: true
val:
Expand Down
10 changes: 4 additions & 6 deletions configs/vision/pathology/online/classification/mhist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ trainer:
filename: best
save_last: true
save_top_k: 1
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryAccuracy}
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryBalancedAccuracy}
mode: &MONITOR_METRIC_MODE ${oc.env:MONITOR_METRIC_MODE, max}
- class_path: lightning.pytorch.callbacks.EarlyStopping
init_args:
min_delta: 0
patience: 51
patience: 70
monitor: *MONITOR_METRIC
mode: *MONITOR_METRIC_MODE
logger:
Expand All @@ -45,11 +45,9 @@ model:
out_features: 1
criterion: torch.nn.BCEWithLogitsLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: &LR_VALUE ${oc.env:LR_VALUE, 0.000625}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trainer:
filename: best
save_last: true
save_top_k: 1
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryAccuracy}
monitor: &MONITOR_METRIC ${oc.env:MONITOR_METRIC, val/BinaryBalancedAccuracy}
mode: &MONITOR_METRIC_MODE ${oc.env:MONITOR_METRIC_MODE, max}
- class_path: lightning.pytorch.callbacks.EarlyStopping
init_args:
Expand Down Expand Up @@ -45,11 +45,9 @@ model:
out_features: 1
criterion: torch.nn.BCEWithLogitsLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: &LR_VALUE ${oc.env:LR_VALUE, 0.01}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down Expand Up @@ -91,7 +89,7 @@ data:
split: test
dataloaders:
train:
batch_size: &BATCH_SIZE ${oc.env:BATCH_SIZE, 4096}
batch_size: &BATCH_SIZE ${oc.env:BATCH_SIZE, 256}
num_workers: &N_DATA_WORKERS ${oc.env:N_DATA_WORKERS, 4}
shuffle: true
val:
Expand Down
6 changes: 2 additions & 4 deletions configs/vision/tests/offline/panda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ model:
output_size: &NUM_CLASSES 6
criterion: torch.nn.CrossEntropyLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: &LR_VALUE ${oc.env:LR_VALUE, 0.00004}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down
6 changes: 2 additions & 4 deletions configs/vision/tests/offline/patch_camelyon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ model:
out_features: 1
criterion: torch.nn.BCEWithLogitsLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: ${oc.env:LR_VALUE, 0.1}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down
6 changes: 2 additions & 4 deletions configs/vision/tests/online/patch_camelyon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ model:
out_features: 1
criterion: torch.nn.BCEWithLogitsLoss
optimizer:
class_path: torch.optim.SGD
class_path: torch.optim.AdamW
init_args:
lr: ${oc.env:LR_VALUE, 0.1}
momentum: 0.9
weight_decay: 0.0
lr: ${oc.env:LR_VALUE, 0.0003}
lr_scheduler:
class_path: torch.optim.lr_scheduler.CosineAnnealingLR
init_args:
Expand Down
Loading

0 comments on commit c6af930

Please sign in to comment.