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

Metrics wraps Metric(s) in Metric(s) #66

Closed DrChainsaw closed 3 years ago

DrChainsaw commented 3 years ago

Sorry for confusing topic.

Perhaps easiest to just point to the place in the code:

struct Metrics <: Callback
    metrics::Tuple
    function Metrics(metrics...)
        return new(Tuple(m isa AbstractMetric ? m : Metric(m) for m in (Loss(), metrics...)))
    end
end

Problem seems to be that Metric is not an AbstractMetric, so if one follows the example from the docstring (metrics = Metrics(Metric(Flux.mse, device = gpu), Metric(Flux.mae, device = gpu)) things will fail with some Metric is not callable as the metricfn will be a Metric due to double wrapping.

lorenzoh commented 3 years ago

Yep, that was an oversight. Thanks for pointing it out!