I don't understand gradient with Flux and Julia

Hi there ! I’m a newcomer to Julia and Flux.
I don’t understand this return with gradient
Here’s my code:

f(x,y) = sum(x .- y)

g(x,y) = sum((x .- y).^2)

gradient(g, [1,2], [3,4])

The answer is

([-4, -4], [4, 4])

But now if I want this one

gradient(f, [1,2], [3,4])

The answer is

(Fill(1, 2), Fill(-1, 2))

What does Fill mean here ? I cant find anything on google.
Thanks a lot for your help

Welcome, @Emmanuel_371. I guess it’s a Fill object from the FillArrays package. Fill(x,2) is equivalent to [x,x], but cheaper in terms of memory allocation and usage.

1 Like

Ohh thanks a lot for your answer ! It helped a lot