GPLaplaceOptimizationProblem.h 3.4 KB

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