Skip to content

Commit a9a71ae

Browse files
committed
feat: add cautious weight decay option in ResNet-finetune
- Introduced `--cautious-weight-decay` argument for flexible optimizer configuration. - Updated `AdamWConfig` to enable cautious weight decay dynamically based on user input.
1 parent bfe2321 commit a9a71ae

File tree

1 file changed

+5
-1
lines changed
  • examples/resnet_finetune/src

1 file changed

+5
-1
lines changed

examples/resnet_finetune/src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ pub struct Args {
104104
#[arg(long, default_value_t = 10)]
105105
patience: usize,
106106

107+
/// Enable cautious weight decay.
108+
#[arg(long, default_value = "false")]
109+
pub cautious_weight_decay: bool,
110+
107111
/// Optimizer Weight decay.
108112
#[arg(long, default_value_t = 5e-4)]
109113
pub weight_decay: f32,
@@ -228,7 +232,7 @@ pub fn train<B: AutodiffBackend>(args: &Args) -> anyhow::Result<()> {
228232
};
229233

230234
let optimizer = AdamWConfig::new()
231-
.with_cautious_weight_decay(true)
235+
.with_cautious_weight_decay(args.cautious_weight_decay)
232236
.with_weight_decay(args.weight_decay)
233237
.init();
234238

0 commit comments

Comments
 (0)