Implementing Function Type for Partial Derivatives
Blakjak88 opened this issue · comments
I am looking for an example of setting up a Function Type in ensmallen for Partial Differentiable Equations. I cannot find one in the test cases.
My question pertains to the Documentation and the setting up of the Function Type. According to the Documentation I need to add two methods:
void Gradient(const arma::mat& x, const size_t j, arma::sp_mat& g);
size_t NumFeatures();
This seems clear, but then the documentation says to implement the rest of the Function Type like the standard Differentiable type.
The problem lies with implementing the Evaluate(const arma::mat& x) method. As I am implementing a function with multiple variables and not just one (hence the need for the partial derivatives), how do you implement Evaluate() when the method can only take one matrix as input?
A simple example would be good, e.g. optimizing a function of J(x, y) = x2 + y2
where the partial derivatives are:
d/dx J(x,y) = 2x
d/dy J(x,y) = 2y
Help would be appreciated.
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions! 👍
Still looking for advice.
https://github.com/mlpack/ensmallen/blob/master/include/ensmallen_bits/problems/himmelblau_function.hpp
https://github.com/mlpack/ensmallen/blob/master/include/ensmallen_bits/problems/himmelblau_function_impl.hpp
Is one example, you can find more examples in the problems
folder - https://github.com/mlpack/ensmallen/tree/master/include/ensmallen_bits/problems