1

Closed

Gradient for a subset of variables

description

It would be great if there was a compile function with the following signature:

Compile(Variable[] variablesForWhichToComputeDerivatives, Variables[] parameters)

one would then call this compiled thing like this, assuming that a,b,c,d,e are all variables:

var compiledTerm= term.Compile(new Variable[] {a,b}, new Variable[] {c,d,e});

var res = compiledTerm.Evaluate(new double[] {3,2}, new double[] {4,5,6});

this would give me back the partial derivatives of the term with respect to a and b, evaluated at a=3, b=2, c=4 etc.

Essentially this would allow me to have constant terms in my function, but I can change the value of these constant terms between calls to evaluate.
Closed Oct 30, 2011 at 11:08 PM by

comments

alexshtf wrote Oct 29, 2011 at 3:08 PM

I hope you know that you can do it right now, by just ignoring the "tail" of the gradient. Right?
The performance hit is not that visible, unless you have a really small number of "real" variables compared to the number of constants.

This is how I will implement the proposed API - right now I prefer correctness. If there is an actual performance problem I will write a specialized implementation that will compute the gradient only for the required variables.

wrote Oct 30, 2011 at 11:08 PM

Resolved with changeset 14187.