tests bias switch

This commit is contained in:
Dhairya Gandhi 2019-10-08 17:18:39 +05:30
parent 040697fb2b
commit b596faaffa
1 changed files with 17 additions and 1 deletions

View File

@ -28,9 +28,25 @@ end
op = bias(ip)
@test sum(op) == prod(size(op))
bias = Conv((2,2), 1=>3, bias = zero(3))
bias = Conv((2,2), 1=>3, bias = Flux.ZeroType((3,)))
op = bias(ip)
@test sum(op) === 0.f0
# Train w/o bias and make sure no convergence happens
# when only bias can be converged
bias = Conv((2, 2), 1=>3, bias = Flux.ZeroType((3,)));
ip = zeros(Float32, 28,28,1,1)
op = zeros(Float32, 27,27,3,1) .+ 2.f0
opt = Descent()
for _ = 1:10^3
gs = gradient(params(bias)) do
Flux.mse(bias(ip), op)
end
Flux.Optimise.update!(opt, params(bias), gs)
end
@test Flux.mse(bias(ip), op) 4.f0
end
@testset "asymmetric padding" begin