# How can I use Zygote to get the gradient

**URL:** <https://discourse.julialang.org/t/how-can-i-use-zygote-to-get-the-gradient/47237>\
**Category:** New to Julia\
**Created:** [September 25, 2020, 2:00am UTC](https://discourse.julialang.org/t/how-can-i-use-zygote-to-get-the-gradient/47237 "2020-09-25T02:00:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yoobi](https://avatars.discourse-cdn.com/v4/letter/y/7993a0/32.png) [@Yoobi](https://discourse.julialang.org/u/Yoobi)\
**Post date:** [September 25, 2020, 2:00am UTC](https://discourse.julialang.org/t/how-can-i-use-zygote-to-get-the-gradient/47237/1 "2020-09-25T02:00:29Z")

</div>

Hello,

I am new here and i just add the pkg Zygote to find the gradient of the function (2+2\*alpha-3)^2, i want to get the value of alpha how can i do that

---

<div class="post-metadata">

**Author:** ![kmundnic](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@kmundnic](https://discourse.julialang.org/u/kmundnic)\
**Post date:** [September 25, 2020, 2:42am UTC](https://discourse.julialang.org/t/how-can-i-use-zygote-to-get-the-gradient/47237/2 "2020-09-25T02:42:50Z")

</div>

What do you mean by “getting the value of alpha”?

In automatic differentiation, when differentiating a function you get a function that you can evaluate on a specific value. For example:

```julia
julia> using Zygote
julia> f(α) = (2 + 2α - 3)^2
julia> f'(1)
4 # equivalent to 2 * (2 + 2 * 1 - 3) * 2 = 4

```

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [September 25, 2020, 2:45am UTC](https://discourse.julialang.org/t/how-can-i-use-zygote-to-get-the-gradient/47237/3 "2020-09-25T02:45:36Z")

</div>

> [@Yoobi](#):
>
> get the value of alpha how can i do tha

I suppose the only way to make sense of it is you want the df/d\alpha at a particular value of alpha.

@Yoobi In general if you make a MWE, it will make it easier to help you [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757)

---

<div class="post-metadata">

**Author:** ![Yoobi](https://avatars.discourse-cdn.com/v4/letter/y/7993a0/32.png) [@Yoobi](https://discourse.julialang.org/u/Yoobi)\
**Post date:** [September 25, 2020, 4:54am UTC](https://discourse.julialang.org/t/how-can-i-use-zygote-to-get-the-gradient/47237/4 "2020-09-25T04:54:53Z")

</div>

> [@kmundnic](#):
>
> `using Zygote`

for example f(x1)=(0+(2+2α-3)^2+4(-1-1024α+5)^4) i want to know how to find the value of the f(x1) where the alpha value is unknown

---

<div class="post-metadata">

**Author:** ![Yoobi](https://avatars.discourse-cdn.com/v4/letter/y/7993a0/32.png) [@Yoobi](https://discourse.julialang.org/u/Yoobi)\
**Post date:** [September 25, 2020, 4:55am UTC](https://discourse.julialang.org/t/how-can-i-use-zygote-to-get-the-gradient/47237/5 "2020-09-25T04:55:28Z")

</div>

yes i want to know how to use the df/d\alpha

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [September 25, 2020, 5:16am UTC](https://discourse.julialang.org/t/how-can-i-use-zygote-to-get-the-gradient/47237/6 "2020-09-25T05:16:13Z")

</div>

> [@Yoobi](#):
>
> for example f(x1)=(0+(2+2α-3)^2+4(-1-1024α+5)^4) i want to know how to find the value of the f(x1) where the alpha value is unknown

i am not comprehending this.

---

<div class="post-metadata">

**Author:** ![Yoobi](https://avatars.discourse-cdn.com/v4/letter/y/7993a0/32.png) [@Yoobi](https://discourse.julialang.org/u/Yoobi)\
**Post date:** [September 25, 2020, 5:30am UTC](https://discourse.julialang.org/t/how-can-i-use-zygote-to-get-the-gradient/47237/7 "2020-09-25T05:30:44Z")

</div>

okay thanks
