Skip to content

Commit

Permalink
avoid a branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Jan 27, 2023
1 parent d7cc49d commit 28ac4c4
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/layers/normalise.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,7 @@ end
@functor Dropout
trainable(a::Dropout) = (;)

function (a::Dropout)(x)
if _isactive(a, x) && a.p != 0
dropout(a.rng, x, a.p; dims=a.dims)
else
x
end
end
(a::Dropout)(x) = dropout(a.rng, x, a.p * _isactive(a, x); dims=a.dims)

testmode!(m::Dropout, mode=true) =
(m.active = (isnothing(mode) || mode == :auto) ? nothing : !mode; m)
Expand Down

0 comments on commit 28ac4c4

Please sign in to comment.