This commit is contained in:
Mike J Innes 2018-03-21 11:25:47 +00:00
parent d09eb8a8e7
commit 4320738d87
2 changed files with 5 additions and 1 deletions

View File

@ -29,7 +29,7 @@ accum!(x, Δ) = x .+ Δ
accum!(x::AbstractArray, Δ) = (x .+= Δ)
function back(x::Tracked, Δ)
x.isleaf && (accum!(x.grad, Δ); return)
x.isleaf && (x.grad = accum!(x.grad, Δ); return)
ref = x.ref -= 1
if isdefined(x, :grad)
x.grad = accum!(x.grad, Δ)

View File

@ -104,4 +104,8 @@ end
@inferred NNlib.conv(param(rand(10,10,3,2)),randn(2,2,3,4))
b = param(rand())
Tracker.back!(b)
@test Tracker.grad(b) == 1
end #testset