Skip to content

Commit 214b05c

Browse files
committed
fuse loops
1 parent 1809dd0 commit 214b05c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/layers/normalise.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ The [`Dropout`](@ref) layer is what you should use in most scenarios.
3030
"""
3131
function dropout(x, p; dims=:, active::Bool=true)
3232
active || return x
33-
y = dropout_mask(x, p, dims=dims)
34-
return x .* y
33+
y = rand!(similar(x, _dropout_shape(x, dims)))
34+
@inbounds @. y = x * _dropout_kernel(y, p, 1-p)
3535
end
3636

37-
@adjoint function dropout(x, p; dims=:, active::Bool=true)
37+
Flux.@adjoint function dropout(x, p; dims=:, active::Bool=true)
3838
active || return x, Δ -> (Δ, nothing)
39-
y = dropout_mask(x, p, dims=dims)
40-
return x .* y, Δ ->.* y, nothing)
39+
y = rand!(similar(x, _dropout_shape(x, dims)))
40+
return x .* _dropout_kernel.(y, p, 1-p), Δ ->.* _dropout_kernel.(y, p, 1-p), nothing)
4141
end
4242

4343
function dropout_mask(x, p; dims=:)

0 commit comments

Comments
 (0)