Loss function names in lowercase
This commit is contained in:
parent
57a52e3375
commit
c4d12e57fe
@ -59,9 +59,8 @@ end
|
|||||||
Kullback Leibler Divergence(KL Divergence)
|
Kullback Leibler Divergence(KL Divergence)
|
||||||
KLDivergence is a measure of how much one probability distribution is different from the other.
|
KLDivergence is a measure of how much one probability distribution is different from the other.
|
||||||
It is always non-negative and zero only when both the distributions are equal everywhere.
|
It is always non-negative and zero only when both the distributions are equal everywhere.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
function KLDivergence(ŷ, y)
|
function kldivergence(ŷ, y)
|
||||||
entropy = sum(y .* log.(y)) *1 //size(y,2)
|
entropy = sum(y .* log.(y)) *1 //size(y,2)
|
||||||
cross_entropy = crossentropy(ŷ, y)
|
cross_entropy = crossentropy(ŷ, y)
|
||||||
return entropy + cross_entropy
|
return entropy + cross_entropy
|
||||||
@ -70,15 +69,13 @@ end
|
|||||||
"""
|
"""
|
||||||
Poisson Loss function
|
Poisson Loss function
|
||||||
Poisson loss function is a measure of how the predicted distribution diverges from the expected distribution.
|
Poisson loss function is a measure of how the predicted distribution diverges from the expected distribution.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Poisson(ŷ, y) = sum(ŷ .- y .* log.(ŷ)) *1 // size(y,2)
|
poisson(ŷ, y) = sum(ŷ .- y .* log.(ŷ)) *1 // size(y,2)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Logcosh Loss function
|
Logcosh Loss function
|
||||||
"""
|
"""
|
||||||
|
|
||||||
logcosh(ŷ, y) = sum(log.(cosh.(ŷ .- y)))
|
logcosh(ŷ, y) = sum(log.(cosh.(ŷ .- y)))
|
||||||
|
|
||||||
Hinge(ŷ, y) = sum(max.(0.0, 1 .- ŷ .* y)) *1 // size(y,2)
|
hinge(ŷ, y) = sum(max.(0.0, 1 .- ŷ .* y)) *1 // size(y,2)
|
||||||
|
|
||||||
|
@ -52,23 +52,23 @@ const ϵ = 1e-7
|
|||||||
|
|
||||||
y = [1 2 3]
|
y = [1 2 3]
|
||||||
y1 = [4.0 5.0 6.0]
|
y1 = [4.0 5.0 6.0]
|
||||||
@testset "KLDivergence" begin
|
@testset "kldivergence" begin
|
||||||
@test Flux.KLDivergence(y, y1) ≈ 4.761838062403337
|
@test Flux.kldivergence(y, y1) ≈ 4.761838062403337
|
||||||
@test Flux.KLDivergence(y, y) ≈ 0
|
@test Flux.kldivergence(y, y) ≈ 0
|
||||||
end
|
end
|
||||||
|
|
||||||
y = [1 2 3 4]
|
y = [1 2 3 4]
|
||||||
y1 = [5.0 6.0 7.0 8.0]
|
y1 = [5.0 6.0 7.0 8.0]
|
||||||
@testset "Hinge" begin
|
@testset "hinge" begin
|
||||||
@test Flux.Hinge(y, y1) ≈ 0
|
@test Flux.hinge(y, y1) ≈ 0
|
||||||
@test Flux.Hinge(y, 0.5 .* y) ≈ 0.125
|
@test Flux.hinge(y, 0.5 .* y) ≈ 0.125
|
||||||
end
|
end
|
||||||
|
|
||||||
y = [0.1 0.2 0.3]
|
y = [0.1 0.2 0.3]
|
||||||
y1 = [0.4 0.5 0.6]
|
y1 = [0.4 0.5 0.6]
|
||||||
@testset "Poisson" begin
|
@testset "poisson" begin
|
||||||
@test Flux.Poisson(y, y1) ≈ 1.0160455586700767
|
@test Flux.poisson(y, y1) ≈ 1.0160455586700767
|
||||||
@test Flux.Poisson(y, y) ≈ 0.5044459776946685
|
@test Flux.poisson(y, y) ≈ 0.5044459776946685
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "logcosh" begin
|
@testset "logcosh" begin
|
||||||
|
Loading…
Reference in New Issue
Block a user