Skip to content

Commit

Permalink
add alpha dropout
Browse files Browse the repository at this point in the history
  • Loading branch information
CarloLucibello committed Mar 23, 2018
1 parent a39eba8 commit 7cef95a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/dropout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,25 @@ function dropback!(p,x,y,dy,dx)
return dx
end


"""
alpha_dropout(x, p)
Dropout associated to the `selu` activation.
Paper Ref.:
Self-Normalizing Neural Networks
https://arxiv.org/abs/1706.02515
"""
function alpha_dropout(x, p)
training = x isa Rec
(p == 0 || !training) && return x

alpha = Float32(-1.758099)
q = Float32(1-p)
x = q*dropout(x .- alpha, p) .+ alpha #set dropped input to alpha
a = 1 / sqrt(q + alpha^2 * q*p)
b = -a * alpha * p
return a*x + b
end

0 comments on commit 7cef95a

Please sign in to comment.