Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce uniform interface for accessing loss function parameters #147

Open
ablaom opened this issue Aug 10, 2021 · 1 comment
Open

Introduce uniform interface for accessing loss function parameters #147

ablaom opened this issue Aug 10, 2021 · 1 comment

Comments

@ablaom
Copy link

ablaom commented Aug 10, 2021

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

@juliohm
Copy link
Member

juliohm commented May 22, 2022

Yes, instead of fixing things with glue code downstream, it would be much better to have it fixed here. The situation described is not ideal, and we appreciate if you can try to improve the interface here instead of wrapping a new one in MLJ.jl next time 🙏🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants