Zygote.jl
Zygote.jl copied to clipboard
Wrong Fill'ed gradient
julia> Zygote.gradient(x -> sum(x .* randn.()), randn(5))
(Fill(-0.30782754826253156, 5),)
This is wrong. The result should be the random vector of coefficients.
Better example, I think:
julia> Zygote.gradient(x -> sum(abs, x .* randn.()), ones(5))
([2.366255991572848, 2.366255991572848, 2.366255991572848, 2.366255991572848, 2.366255991572848],)
julia> Zygote.gradient(x -> sum(x .* randn.()), ones(5))
(Fill(0.16740972975253307, 5),)
From FillArrays's readme:
julia> broadcast(_ -> rand(), Fill("pi", 2,5))
2×5 Fill{Float64}, with entries equal to 0.6010457938025311
julia> ones(1,5) .+ (_ -> rand()).(Fill("vec", 2))
2×5 Matrix{Float64}:
1.83695 1.83695 1.83695 1.83695 1.83695
1.83695 1.83695 1.83695 1.83695 1.83695
julia> Fill(1.0, 2, 5) .+ rand.() # but this is not altered
2×5 Matrix{Float64}:
1.50444 1.16431 1.55788 1.70783 1.00847
1.61302 1.968 1.6408 1.02243 1.18068