Flux.jl/test/layers.jl
CarloLucibello 2e1ed4c3fc add dropout
2017-10-23 10:12:53 +02:00

24 lines
517 B
Julia

@testset "dropout" begin
x = [1.,2.,3.]
@test x === Dropout(0.1, mode=:eval)(x)
@test x === Dropout(0, mode=:train)(x)
@test all(zeros(x) .== Dropout(1, mode=:train)(x))
x = rand(100)
m = Dropout(0.9)
y = m(x)
@test count(a->a==0, y) > 50
setmode!(m, :eval)
y = m(x)
@test count(a->a==0, y) == 0
x = rand(100)
m = Chain(Dense(100,100),
Dropout(0.9))
y = m(x)
@test count(a->a.data[] == 0, y) > 50
setmode!(m, :eval)
y = m(x)
@test count(a->a.data[] == 0, y) == 0
end