Skip to content

Where is EarlyStopping searching for metrics? #670

@felixkreuk

Description

@felixkreuk

Where is EarlyStopping search for metrics?

Code

    def validation_end(self, outputs):
        ...
        metrics = {
        'val_acc': val_acc,
        'val_loss': val_loss
        }
        ...
        output = OrderedDict({
            'val_acc':  torch.tensor(metrics['val_acc']),
            'val_loss': torch.tensor(metrics['val_loss']),
            'progress_bar': metrics,
            'log': metrics
        })
        return output

if I attempt to early stop according to val_acc I get the following error:

RuntimeWarning: Early stopping conditioned on metric 'val_acc' which is not available. Available metrics are: loss,train_loss

The metrics mentioned (loss,train_loss) are from training_step from what I could find.

I guess I'm doing something wrong, could anyone point me in the correct direction?

  • OS: Ubuntu
  • Packaging: pip
  • Version 0.5.3.2

Update #1: the same code works with version 0.5.1. Bug in 0.5.3?

Update #2:
I found that this line in trainer/training_loop.py:

self.callback_metrics = {k: v for d in all_callback_metrics for k, v in d.items()}

From what I see, before this line is executed, self.callback_metrics contains val_acc. After this line values that were put in callback_metrics after validation are gone, therefore EarlyStopping can't find them. Can anyone confirm this is an issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions