Flux.jl/test/layers.jl
2017-10-23 16:23:29 +02:00

27 lines
564 B
Julia

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