Closed micahscopes closed 9 months ago
Probably some form of a custom wrapper type in between your problem and the Gradient/CostFunction
traits which computes both and then provides the traits with the cached data
Sorry about the late reply! @TheIronBorn is right, some form of "precomputing and caching" is necessary. One thing to look out for may be (depending on what you are trying to do exactly) the order in which cost and gradient are computed in the solver you are using. Furthermore, if a solver uses a line search, this could require additional measures in your solution.
I'm working on a problem where the gradient and cost functions share some common computation, including some weights that take quadratic complexity.
Short of implementing a custom solver, what's the right way in argmin to share some computations between the gradient and cost function implementations?