The following function throws
function get_error(G, E, x) n, m = size(G) Ê = repeat(E, inner=(1, m)) Ĝ = repeat(G, inner=(1, m)) return Ĝ * prod(x.^Ê, dims=1)' end G = [0. 1.5 1.; 1.5 1. 1.5] # Float matrix with non-integer values E = [0 0 1; 0 1 0] # Int matrix x = [1., 2.] gs = jacobian(get_error, G, E, x)
get_error() with the following function (where just the standart
repeat() is used – so the computed result is different) works just fine.
function get_no_error(G, E, x) n, m = size(G) Ê = repeat(E, 1, m) Ĝ = repeat(G, inner=(1, m)) return Ĝ * prod(x.^Ê, dims=1)' end
Is there a way to reformulate
get_error() so that autodiff works also for the inner repeat?
A method to just ignore the derivative for the integer matrix
E and only return the derivative for
x would also work for me.