# Gradient of jacobian in Flux v0.10 (zygote)

**URL:** <https://discourse.julialang.org/t/gradient-of-jacobian-in-flux-v0-10-zygote/34572>\
**Category:** General Usage\
**Tags:** machine-learning\
**Created:** [February 13, 2020, 1:22pm UTC](https://discourse.julialang.org/t/gradient-of-jacobian-in-flux-v0-10-zygote/34572 "2020-02-13T13:22:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Post date:** [February 13, 2020, 1:22pm UTC](https://discourse.julialang.org/t/gradient-of-jacobian-in-flux-v0-10-zygote/34572/1 "2020-02-13T13:22:31Z")

</div>

Hi all,

in our project on modelling probability distributions we need to calculate a gradient of a function, which involves jacobian of the model. Zygote (Flux) crashes with the output that mutating arrays are not support. Does anyone know, how to do this? Our minimum working example would look like this

```julia

function jacobian(f, x)
    m = length(x)
    bf = Zygote.Buffer(x,m, m)
    for i in 1:m
        bf[i, :] = gradient(x -> f(x)[i], x)[1]
    end
    copy(bf)
end

gs = gradient(() -> sum(jacobian(m, x0)), ps)

```

Thanks for help in advance.  
Tomas
