-
Notifications
You must be signed in to change notification settings - Fork 34
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
Multivariate Loss #39
Comments
Would that make softmax function value{T<:Number}(::Softmax, target::Int, output::AbstractVector{T})
return logsumexp(output) - output[target]
end We should have """
logsumexp(x)
Computes `log(sum(exp(x)))` of a vector `x` in a numerically stable manner
"""
function logsumexp{T<:Number}(x::AbstractVector{T})
m = maximum(x) # subtracting m prevents overflow
sumexp = zero(T)
for i in eachindex(x)
sumexp += exp(x[i]-m)
end
return log(sumexp) + m
end All of this seems a bit different (incompatible?) from what you had in mind for the multivariate hinge loss, could you expand on your thoughts there? |
Actually, that sounds like a good idea. The multinomial loss doesn't require the outputs to be produced with
If it is not in StatsBase yet, then we should define it in LearnBase in my opinion |
Found it! |
We could also consider a shorter |
Partially done. For distance based losses this can now be achieved with the average modes. No support for multinomial classification losses yet, though |
https://github.com/madeleineudell/LowRankModels.jl has implementations of several multivariate loss functions for ordinal and categorical variables (OvALoss, BvSLoss, etc.). |
I'd like to start implementing the multi-category loss functions like MultinomialLoss, Multiclass SVM, and One-vs-all, but I'm not sure what the convention should be or how they play with LabelEncodings (i.e. output is some kind of vector, but is the target something encoded in a one-hot scheme or an index?). LowRankModels uses something akin to the Indices encoding scheme for targets, but I think this would be a productive discussion to have. cc: @madeleineudell |
@mihirparadkar @kvmanohar22 any progress regarding the multi class losses? I am currently needing them for a research paper. Can work on it right away if you guys allow. |
Closing this as we already have |
One bridge we have to cross sooner or later are multiclass problems. There are mutliclass extensions or formulations for a couple of losses that we have.
A particular interesting example is the hinge loss. In a multinomial setting the targets could be indices, such as
[1,2,3,1]
, which would violate our current idea of atargetdomain
being[-1,1]
.One solution could be to think of the multivariate version as separate of the binary one. For example we could lift it like this:
Multivariate{L1HingeLoss}
. This could then have it's owntargetdomain
and other properties. It would also avoid potential ambiguities when it comes to dispatching on the typestargets
andoutput
. I am not sure we could be certain of dealing with a multivariate vs binary case just based on the parameter typesThe text was updated successfully, but these errors were encountered: