Skip to content

Commit 2dca7ec

Browse files
committed
add comments
1 parent 3c11587 commit 2dca7ec

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/layers/normalise.jl

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ function _track_stats!(
275275
μnew = vec(N reduce_dims ? μ : mean(μ, dims=N))
276276
σ²new = vec(N reduce_dims ? σ² : mean(σ², dims=N))
277277

278+
# ForwardDiff.value removes Dual, was an error, issue #2122
278279
bn.μ .= value.(res_mtm .* bn.μ .+ mtm .* μnew)
279280
bn.σ² .= value.(res_mtm .* bn.σ² .+ mtm .* (m / (m - one(V))) .* σ²new)
280281
return nothing

test/layers/normalisation.jl

+1
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ end
472472
@test ForwardDiff.jacobian(bn, rand(Float32, 3, 4)) isa Matrix{Float32}
473473
iszero(bn.μ) # true, but ideally it would automatically choose trainmode
474474
Flux.trainmode!(bn)
475+
# This was an error, https://github.com/FluxML/Flux.jl/issues/2122
475476
@test ForwardDiff.jacobian(bn, rand(Float32, 3, 4)) isa Matrix{Float32}
476477
@test !iszero(bn.μ)
477478
end

0 commit comments

Comments
 (0)