Merge pull request #592 from MJ10/master
Layer normalisation for images
This commit is contained in:
commit
53875a85a1
@ -40,12 +40,12 @@ but it is more numerically stable.
|
|||||||
logitbinarycrossentropy(logŷ, y) = (1 - y)*logŷ - logσ(logŷ)
|
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)
|
function normalise(x::AbstractArray, dims::Int=1)
|
||||||
μ′ = mean(x, dims = 1)
|
μ′ = mean(x, dims = dims)
|
||||||
σ′ = std(x, dims = 1, mean = μ′, corrected=false)
|
σ′ = std(x, dims = dims, mean = μ′, corrected=false)
|
||||||
return (x .- μ′) ./ σ′
|
return (x .- μ′) ./ σ′
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user