Skip to content
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

Epsilon change in normalise for stability #2421

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/layers/stateless.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Normalise `x` to mean 0 and standard deviation 1 across the dimension(s) given by `dims`.
Per default, `dims` is the last dimension.
`eps` is a small term added to the denominator for numerical stability.
`eps` is a small term added to the denominator/square root for numerical stability.
billera marked this conversation as resolved.
Show resolved Hide resolved

# Examples
```jldoctest
Expand Down Expand Up @@ -37,8 +37,8 @@ true
@inline function normalise(x::AbstractArray; dims=ndims(x), eps=ofeltype(x, 1e-5), ϵ=nothing)
ε = _greek_ascii_depwarn(ϵ => eps, :InstanceNorm, "ϵ" => "eps")
μ = mean(x, dims=dims)
σ = std(x, dims=dims, mean=μ, corrected=false)
return @. (x - μ) / + ε)
σ² = var(x, dims=dims, mean=μ, corrected=false)
return @. (x - μ) / sqrt(σ² + ε^2)
end

"""
Expand Down
Loading