How to compute Jacobian matrix?

Hi
For a task i needed to compute a derivative of output F(x) given weights W ( ∂F(x,w))/∂w ), is there any way to get the derivation matrix in Nengo ?

Hi @hamed,

The core of Nengo doesn’t have any tools for calculating Jacobian matrices, but since NengoDL is built on top of TensorFlow, it can do automatic differentiation to find Jacobians. There is some discussion about how to do that in this thread. It would end up looking something like

    gradients = tf.gradients(sim.tensor_graph.probe_arrays[p], 
                             sim.tensor_graph.input_ph[x])
    dydx = sim.sess.run(gradients, feed_dict=sim._fill_feed(
        n_steps, training=True)
    )

but the specifics would change depending on the network you have set up. The derivative isn’t exactly the Jacobian, though it’s close; there is also a Jacobian function in TensorFlow, which might prove useful. The first step will be to set up a network computing F(x) that works with NengoDL, so if you go that route start there and we can help more once we have the full network details.

We have also done some work computing Jacobians in the context of force control (cc @travis.dewolf and @Pawel), so if your application is related to robotics, they can likely help out as well.