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

Ordinalizing Margin Losses #80

Open
mihirparadkar opened this issue Jun 25, 2017 · 3 comments
Open

Ordinalizing Margin Losses #80

mihirparadkar opened this issue Jun 25, 2017 · 3 comments

Comments

@mihirparadkar
Copy link
Collaborator

Right now LowRankModels implements an OrdinalHingeLoss which is related to the HingeLoss. However, as we port the losses over to LossFunctions, I was thinking that this ordinalization is not unique to the HingeLoss, but could be used for any margin loss (LogisticLoss, SquaredHingeLoss, etc.). The Rennie paper that describes the ordinal hinge loss ( http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.124.9242 ) seems to confirm this.

Perhaps we should reimplement it generically across margin losses by using a wrapper type a la ScaledLosses from LossFunctions (I'm thinking OrdinalMarginLoss{T<:MarginLoss, min, max} or something like that).

@mihirparadkar
Copy link
Collaborator Author

I've started writing code to do this for arbitrary margin losses, but I think the loop for explicit summation is necessary. I don't think the clever tricks in OrdinalHingeLoss generalize to other losses like squared hinge or logistic. However, since the number of ordinal levels should usually be relatively small ( <10 or so), the loop could be optimized by unrolling, which is implemented in Unroll.jl as a macro.

@madeleineudell
Copy link
Owner

madeleineudell commented Jun 27, 2017 via email

@mihirparadkar
Copy link
Collaborator Author

I opened the PR, but even with ~5 levels, the OrdinalMarginLoss(HingeLoss(), 5) is 6 times slower than an ordinary MarginLoss when applied to an array. I think loop unrolling using @nexprs will definitely help a lot, especially because ordinal losses usually don't have a lot of levels.

Of course, in order to allow this unrolling, I have to include the number of levels as a type parameter instead of as a field, and then use @generated along with @nexprs so I can get that unrolling at compile-time.

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

No branches or pull requests

2 participants