# I don't understand gradient with Flux and Julia

**URL:** https://discourse.julialang.org/t/i-dont-understand-gradient-with-flux-and-julia/67552
**Category:** New to Julia
**Tags:** flux
**Created:** [September 2, 2021, 6:41am UTC](https://discourse.julialang.org/t/i-dont-understand-gradient-with-flux-and-julia/67552 "2021-09-02T06:41:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Emmanuel\_371](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emmanuel_371/32/28803_2.png) [@Emmanuel\_371](https://discourse.julialang.org/u/Emmanuel_371)
#### Post date: [September 2, 2021, 6:41am UTC](https://discourse.julialang.org/t/i-dont-understand-gradient-with-flux-and-julia/67552/1 "2021-09-02T06:41:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [September 2, 2021, 9:12am UTC](https://discourse.julialang.org/t/i-dont-understand-gradient-with-flux-and-julia/67552/2 "2021-09-02T09:12:16Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Emmanuel\_371](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emmanuel_371/32/28803_2.png) [@Emmanuel\_371](https://discourse.julialang.org/u/Emmanuel_371)
#### Post date: [September 2, 2021, 9:26am UTC](https://discourse.julialang.org/t/i-dont-understand-gradient-with-flux-and-julia/67552/3 "2021-09-02T09:26:53Z")

</div>

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