Avoid unnecessary conversion

This initialization works for both cpu and gpu
This commit is contained in:
Fredrik Bagge Carlson 2019-11-19 16:31:04 +08:00 committed by GitHub
parent 967cc1c175
commit 2da22f31f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -283,7 +283,7 @@ ADAGrad(η = 0.1) = ADAGrad(η, IdDict())
function apply!(o::ADAGrad, x, Δ)
η = o.eta
acc = get!(o.acc, x, fill(ϵ, size(x)))::typeof(x)
acc = get!(o.acc, x, fill!(zero(x), ϵ))::typeof(x)
@. acc += Δ^2
@. Δ *= η / (acc + ϵ)
end