mirror of
https://github.com/tig-foundation/tig-monorepo.git
synced 2026-02-21 10:27:49 +08:00
Save every epoch where loss improves.
Some checks failed
Test Workspace / Test Workspace (push) Has been cancelled
Some checks failed
Test Workspace / Test Workspace (push) Has been cancelled
This commit is contained in:
parent
c4f12d7350
commit
0a12ff6fe1
@ -381,7 +381,6 @@ pub fn training_loop(
|
||||
)?;
|
||||
|
||||
let mut lowest_loss = f32::INFINITY;
|
||||
let mut last_save_epoch = None;
|
||||
let mut epochs_no_improvement = 0;
|
||||
let mut prev_train_loss = None;
|
||||
let mut prev_validation_loss = None;
|
||||
@ -568,17 +567,10 @@ pub fn training_loop(
|
||||
if avg_val_loss < lowest_loss - min_loss_delta {
|
||||
lowest_loss = avg_val_loss;
|
||||
epochs_no_improvement = 0;
|
||||
if !last_save_epoch
|
||||
.as_ref()
|
||||
.is_some_and(|&x| epoch - x < max_epochs / 20)
|
||||
{
|
||||
last_save_epoch = Some(epoch);
|
||||
save_solution(&to_solution(&model, epoch + 1, stream.clone())?)?;
|
||||
}
|
||||
save_solution(&to_solution(&model, epoch + 1, stream.clone())?)?;
|
||||
} else {
|
||||
epochs_no_improvement += 1;
|
||||
if epochs_no_improvement >= patience {
|
||||
save_solution(&to_solution(&model, epoch + 1, stream.clone())?)?;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user