diff --git a/src/layers/stateless.jl b/src/layers/stateless.jl index 5f457057..2fd98815 100644 --- a/src/layers/stateless.jl +++ b/src/layers/stateless.jl @@ -16,33 +16,33 @@ mse(ŷ, y) = sum((ŷ .- y).^2) * 1 // length(y) """ - msle(ŷ, y; ϵ = eps.(Float64.(ŷ))) + msle(ŷ, y; ϵ=eps(eltype(ŷ))) -Returns the mean of the squared logarithmic errors `sum((log.(ŷ + ϵ) .- log.(y + ϵ)).^2) / length(y)`. +Returns the mean of the squared logarithmic errors `sum((log.(ŷ .+ ϵ) .- log.(y .+ ϵ)).^2) / length(y)`. The `ϵ` term provides numerical stability. This error penalizes an under-predicted estimate greater than an over-predicted estimate. """ -msle(ŷ, y; ϵ = eps.(ŷ)) = sum((log.(ŷ + ϵ).-log.(y + ϵ)).^2) * 1 // length(y) +msle(ŷ, y; ϵ=eps(eltype(ŷ))) = sum((log.(ŷ .+ ϵ) .- log.(y .+ ϵ)).^2) * 1 // length(y) """ - huber_loss(ŷ, y; delta = 1.0) + huber_loss(ŷ, y; δ=1.0) -Computes the mean of the Huber loss given the prediction `ŷ` and true values `y`. By default, delta is set to 1.0. +Computes the mean of the Huber loss given the prediction `ŷ` and true values `y`. By default, δ is set to 1.0. - | 0.5*|ŷ - y|, for |ŷ - y| <= delta + | 0.5*|ŷ - y|, for |ŷ - y| <= δ Hubber loss = | - | delta*(|ŷ- y| - 0.5*delta), otherwise + | δ*(|ŷ - y| - 0.5*δ), otherwise [`Huber Loss`](https://en.wikipedia.org/wiki/Huber_loss). """ -function huber_loss(ŷ, y; delta = eltype(ŷ)(1)) - abs_error = abs.(ŷ.-y) - temp = abs_error.