Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/layers/normalisation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,19 @@ end

x = randn(1000) # large enough to prevent flaky test
m = AlphaDropout(0.5; rng_kwargs...)
q = 0.5
u = mean(x)
α′ = -1.7580993408473766

y = evalwgrad(m, x)
# Should preserve unit mean and variance
@test mean(y) ≈ 0 atol=0.2
@test var(y) ≈ 1 atol=0.2

# Should check that the mean and variance matches the formula
# E(xd + α′(1-d)) = qu + (1-q)α′
@test mean(y) ≈ (q*u) + ((1-q)*α′)

testmode!(m, true) # should override istraining
@test evalwgrad(m, x) == x

Expand Down