Skip to content

Commit

Permalink
add support for n-dimensional input to normalise layer
Browse files Browse the repository at this point in the history
  • Loading branch information
MJ10 committed Feb 4, 2019
1 parent 329c8f8 commit 93d694b
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.
Normalise each column of `x` to mean 0 and standard deviation 1, where `dims`(default value is 1) is the number of dimensions in input `x`.
"""
function normalise(x::AbstractVecOrMat)
μ′ = mean(x, dims = 1)
σ′ = std(x, dims = 1, mean = μ′)
function normalise(x::AbstractArray, dims::Int=1)
μ′ = mean(x, dims = dims)
σ′ = std(x, dims = dims, mean = μ′)
return (x .- μ′) ./ σ′
end

0 comments on commit 93d694b

Please sign in to comment.