FluxML / FluxTraining.jl

A flexible neural net training library inspired by fast.ai
https://fluxml.ai/FluxTraining.jl
MIT License
118 stars 25 forks source link

Allow restricting phases during which a `Metric` runs #84

Closed lorenzoh closed 2 years ago

lorenzoh commented 3 years ago

This would allow running expensive metrics only during validation phases.

Currently, you can pass functions or a Metric to the Metrics callback:

cb = Metrics(
    accuracy,
    Metric(Flux.mse),
    Metric(expensivemetricfn)
)

This feature would add a phase argument to Metric:

cb = Metrics(
    accuracy,
    Metric(Flux.mse),
    Metric(expensivemetricfn, phase = AbstractValidationPhase)
)

In case expensivemetricfn takes a long time to evaluate, this saves time during training while giving important information during the (usually much shorter) validation phases.