Skip to content

Introduce uniform interface for accessing loss function parameters #147

@ablaom

Description

@ablaom

Perhaps I'm missing something, but this does not appear to exist at present. For most losses with a parameter, you access using property, as in

loss = HuberLoss(0.5)

julia> loss.d
0.5

But for an LPDistLoss there no field for p, only a type parameter:

julia> loss=LPDistLoss(2.5)
LPDistLoss{2.5}()

julia> propertynames(loss)
()

One suggestion would be overload Base.getproperty/Base.propertynames for cases of the second kind (I think these are just LPDistLoss, L1DistLoss, L2DistLoss, but I haven't checked lately), or to implement StatsBase.params or both.

I ran into this issue when wrapping the losses for use in MLJ and was obliged to write my own interface, which is not robust to extensions of LossFunctions.jl

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions