From d9ea5fba761bb8471bac878237a7b4b836dbcf00 Mon Sep 17 00:00:00 2001 From: Ian Date: Tue, 3 Mar 2020 11:55:39 -0500 Subject: [PATCH] add `active` helpers for other normalise layers --- src/layers/normalise.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/layers/normalise.jl b/src/layers/normalise.jl index 0647e6b4..f9ef4de8 100644 --- a/src/layers/normalise.jl +++ b/src/layers/normalise.jl @@ -40,6 +40,8 @@ mutable struct Dropout{F,D} active::Union{Bool, Nothing} end +Dropout(p, dims) = Dropout(p, dims, nothing) + function Dropout(p; dims = :) @assert 0 ≤ p ≤ 1 Dropout{typeof(p),typeof(dims)}(p, dims, nothing) @@ -77,6 +79,8 @@ mutable struct AlphaDropout{F} end end +AlphaDropout(p) = AlphaDropout(p, nothing) + function (a::AlphaDropout)(x) _isactive(a) || return x λ = eltype(x)(1.0507009873554804934193349852946) @@ -253,6 +257,8 @@ mutable struct InstanceNorm{F,V,W,N} active::Union{Bool, Nothing} end +InstanceNorm(λ, β, γ, μ, σ², ϵ, momentum) = InstanceNorm(λ, β, γ, μ, σ², ϵ, momentum, nothing) + InstanceNorm(chs::Integer, λ = identity; initβ = (i) -> zeros(Float32, i), initγ = (i) -> ones(Float32, i), ϵ = 1f-5, momentum = 0.1f0) = InstanceNorm(λ, initβ(chs), initγ(chs), @@ -344,6 +350,8 @@ mutable struct GroupNorm{F,V,W,N,T} active::Union{Bool, Nothing} end +GroupNorm(G, λ, β, γ, μ, σ², ϵ, momentum) = GroupNorm(G, λ, β, γ, μ, σ², ϵ, momentum, nothing) + GroupNorm(chs::Integer, G::Integer, λ = identity; initβ = (i) -> zeros(Float32, i), initγ = (i) -> ones(Float32, i), ϵ = 1f-5, momentum = 0.1f0) = GroupNorm(G, λ, initβ(chs), initγ(chs),