Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test for Alpha Dropout #2367

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
Loading