Skip to content

Commit

Permalink
Merge pull request #592 from MJ10/master
Browse files Browse the repository at this point in the history
Layer normalisation for images
  • Loading branch information
DhairyaLGandhi authored Feb 5, 2019
2 parents 940b1e6 + 046f7b4 commit 53875a8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/layers/stateless.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ but it is more numerically stable.
logitbinarycrossentropy(logŷ, y) = (1 - y)*logŷ - logσ(logŷ)

"""
normalise(x::AbstractVecOrMat)
normalise(x::AbstractArray, dims::Int=1)
Normalise each column of `x` to mean 0 and standard deviation 1.
Normalises x to mean 0 and standard deviation 1, across the dimensions given by dims. Defaults to normalising over columns.
"""
function normalise(x::AbstractVecOrMat)
μ′ = mean(x, dims = 1)
σ′ = std(x, dims = 1, mean = μ′, corrected=false)
function normalise(x::AbstractArray, dims::Int=1)
μ′ = mean(x, dims = dims)
σ′ = std(x, dims = dims, mean = μ′, corrected=false)
return (x .- μ′) ./ σ′
end

0 comments on commit 53875a8

Please sign in to comment.