Loss function names in lowercase

This commit is contained in:
thebhatman 2019-03-26 03:09:48 +05:30
parent 57a52e3375
commit c4d12e57fe
2 changed files with 12 additions and 15 deletions

View File

@ -59,9 +59,8 @@ end
Kullback Leibler Divergence(KL Divergence)
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.
"""
function KLDivergence(, y)
function kldivergence(, y)
entropy = sum(y .* log.(y)) *1 //size(y,2)
cross_entropy = crossentropy(, y)
return entropy + cross_entropy
@ -70,15 +69,13 @@ end
"""
Poisson Loss function
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(, 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)

View File

@ -52,23 +52,23 @@ const ϵ = 1e-7
y = [1 2 3]
y1 = [4.0 5.0 6.0]
@testset "KLDivergence" begin
@test Flux.KLDivergence(y, y1) 4.761838062403337
@test Flux.KLDivergence(y, y) 0
@testset "kldivergence" begin
@test Flux.kldivergence(y, y1) 4.761838062403337
@test Flux.kldivergence(y, y) 0
end
y = [1 2 3 4]
y1 = [5.0 6.0 7.0 8.0]
@testset "Hinge" begin
@test Flux.Hinge(y, y1) 0
@test Flux.Hinge(y, 0.5 .* y) 0.125
@testset "hinge" begin
@test Flux.hinge(y, y1) 0
@test Flux.hinge(y, 0.5 .* y) 0.125
end
y = [0.1 0.2 0.3]
y1 = [0.4 0.5 0.6]
@testset "Poisson" begin
@test Flux.Poisson(y, y1) 1.0160455586700767
@test Flux.Poisson(y, y) 0.5044459776946685
@testset "poisson" begin
@test Flux.poisson(y, y1) 1.0160455586700767
@test Flux.poisson(y, y) 0.5044459776946685
end
@testset "logcosh" begin