Skip to content

Commit

Permalink
scaled loss test
Browse files Browse the repository at this point in the history
  • Loading branch information
Evizero committed Jan 12, 2017
1 parent 9f9ea51 commit 420a696
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/supervised/scaledloss.jl
Expand Up @@ -14,7 +14,7 @@ following signature: `scaledloss(loss, Val{K})`
"""
function scaledloss end

_serror() = throw(ArgumentError("Scale factor K has to be strictly positive."))
@inline _serror() = throw(ArgumentError("Scale factor K has to be strictly positive."))

for KIND in (:MarginLoss, :DistanceLoss, :SupervisedLoss)
SCALEDKIND = Symbol(:Scaled, KIND)
Expand Down Expand Up @@ -44,6 +44,7 @@ for KIND in (:MarginLoss, :DistanceLoss, :SupervisedLoss)
immutable ($SCALEDKIND){L<:$KIND,K} <: $KIND
loss::L

($SCALEDKIND)() = typeof(K) <: Number && K > 0 ? new(L()) : _serror()
($SCALEDKIND)(args...) = typeof(K) <: Number && K > 0 ? new(L(args...)) : _serror()
($SCALEDKIND)(loss::L) = typeof(K) <: Number && K > 0 ? new(loss) : _serror()
end
Expand Down

0 comments on commit 420a696

Please sign in to comment.