GPLaplaceOptimizationProblem.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * @file GPLaplaceOptimizationProblem.h
  3. * @author Erik Rodner
  4. * @date 12/09/2009
  5. */
  6. #ifndef _NICE_OBJREC_GPREGRESSIONOPTIMIZATIONPROBLEMINCLUDE
  7. #define _NICE_OBJREC_GPREGRESSIONOPTIMIZATIONPROBLEMINCLUDE
  8. #include "core/vector/VVector.h"
  9. #include "vislearning/math/kernels/ParameterizedKernel.h"
  10. #include "core/optimization/OptimizationProblemFirst.h"
  11. #include "vislearning/math/kernels/KernelData.h"
  12. #include "LaplaceApproximation.h"
  13. #include "LikelihoodFunction.h"
  14. namespace OBJREC {
  15. /** @class GPLaplaceOptimizationProblem
  16. * Hyperparameter Optimization Problem for GP with Laplace Approximation
  17. *
  18. * @author Erik Rodner
  19. */
  20. class GPLaplaceOptimizationProblem : public NICE::OptimizationProblemFirst
  21. {
  22. protected:
  23. KernelData *kernelData;
  24. NICE::VVector y;
  25. double bestAvgLooError;
  26. NICE::Vector bestLooParameters;
  27. ParameterizedKernel *kernel;
  28. bool verbose;
  29. const LikelihoodFunction *likelihoodFunction;
  30. std::vector<LaplaceApproximation *> laplaceApproximation;
  31. public:
  32. /** initialize the optimization problem of laplace approximation integrated in
  33. * GP
  34. * @param kernelData object containing kernel matrix and other stuff
  35. * @param y labels which have to -1 or 1
  36. * @param kernel a parameterized kernel which provides derivations
  37. * @param likelihoodFunction the type of the likelihood p(y_i|f_i), e.g. cumulative gaussian
  38. * @param laplaceApproximation object containing cached matrices of the laplaceApproximation
  39. * @param verbose print some status messages for debugging and boring work days
  40. **/
  41. GPLaplaceOptimizationProblem ( KernelData *kernelData, const NICE::Vector & y,
  42. ParameterizedKernel *kernel, const LikelihoodFunction *likelihoodFunction,
  43. LaplaceApproximation *laplaceApproximation,
  44. bool verbose );
  45. /** initialize the multi-task optimization problem of laplace approximation
  46. * integrated in GP
  47. * @param kernelData object containing kernel matrix and other stuff
  48. * @param y vector of labels which have to -1 or 1
  49. * @param kernel a parameterized kernel which provides derivations
  50. * @param likelihoodFunction the type of the likelihood p(y_i|f_i), e.g. cumulative gaussian
  51. * @param laplaceApproximation object containing cached matrices of the laplaceApproximation
  52. * @param verbose print some status messages for debugging and boring work days
  53. **/
  54. GPLaplaceOptimizationProblem ( KernelData *kernelData, const NICE::VVector & y,
  55. ParameterizedKernel *kernel, const LikelihoodFunction *likelihoodFunction,
  56. const std::vector<LaplaceApproximation *> & laplaceApproximation,
  57. bool verbose );
  58. /** R.I.P. */
  59. ~GPLaplaceOptimizationProblem();
  60. /** compute the negative log likelihood of the laplace approximation integrated GP */
  61. double computeObjective();
  62. /** compute the gradient of the negative log likelihood of the laplace approximation */
  63. void computeGradient( NICE::Vector& newGradient );
  64. /** set hyperparameters of the current kernel */
  65. void setParameters ( const NICE::Vector & newParameters ) { parameters() = newParameters; };
  66. /** use loo parameters */
  67. void useLooParameters ();
  68. /** update cached stuff like cholesky factorization (KernelData.h) */
  69. void update();
  70. };
  71. }
  72. #endif