MOE
MOE copied to clipboard
[C++] Make covariance objects constructible from Python
Right now, the boost C++/Python interface assumes the user wants SquareExponential
. Operations that require covariance classes currently just accept a vector of hyperparameters, and then they always construct the sqexp object. So far, this hasn't been a limitation for our use cases.
But the C++ has several more covariance options but they are not available through the python interface (without recompilation, yuck).
Instead, we should...
-
Expose covariance objects to Python via
class_
. These objects should come with the ability to get the number of hyperparameters and get/set hyperparameters at a minimum. It'd be nice if they could also compute covariance and its various derivatives. This would be easier with #159 done so we wouldn't need a ton of wrapper functions. -
Set up SquareExponential in
python/cpp_wrappers/covariance.py
to construct the object from step 1. -
For the functions exposed to python, instead of:
foo(double * hyperparameters, ...) { SquareExponential cov(hyperparameters); do_stuff(cov, ...); }
We should now do:
foo(CovarianceInterface& cov, ...) { do_stuff(cov, ...); }
and in Python, change calls to
foo(cov, ...)
where cov is one of the objects constructed from step 2 instead of just passing hyperparams around.
C++ covariance functions all inherit (virtually) from CovarianceInterface, so no modification outside of the gpp_python_*
files will be necessary.