Hi, I’m new to Julia and looking to learn more about Autodiff in julia. I’ve matrix multiplication and want to get the derivative of a matrix wrt to a matrix.

For example in the equations below, I want to compute \frac{\partial X_4}{\partial X_1}, where both X_1 and X_4 are matrices (W_i are also matrices and f is some function applied to each element of the matrix) .

X_1 = X_0 \cdot W_1

X_2 = f(X_1)

X_3 = X_2 \cdot W_2

X_4 = f(X_3)

This is very similar to NN, but here my **output is not a scalar**. I want to use forward mode autodiff for this however I can’t figure out how to do this using `ForwardDiff`

package.

Apart from this, it would be great if someone can explain how chain rule would work in this case (I’m familiar with reverse mode autodiff where output is scalar but I can’t figure out the mathematics behind something similar but in forward mode).

I hope I’ve explained my problem clearly.

Thanks