Skip to content

Commit 28ac4c4

Browse files
committed
avoid a branch
1 parent d7cc49d commit 28ac4c4

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/layers/normalise.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@ end
7474
@functor Dropout
7575
trainable(a::Dropout) = (;)
7676

77-
function (a::Dropout)(x)
78-
if _isactive(a, x) && a.p != 0
79-
dropout(a.rng, x, a.p; dims=a.dims)
80-
else
81-
x
82-
end
83-
end
77+
(a::Dropout)(x) = dropout(a.rng, x, a.p * _isactive(a, x); dims=a.dims)
8478

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

0 commit comments

Comments
 (0)