SHOGUN  6.1.3
LaplaceInference.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) The Shogun Machine Learning Toolbox
3  * Written (w) 2014 Wu Lin
4  * Written (W) 2013 Roman Votyakov
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * The views and conclusions contained in the software and documentation are those
28  * of the authors and should not be interpreted as representing official policies,
29  * either expressed or implied, of the Shogun Development Team.
30  *
31  */
32 
34 
35 
38 
39 using namespace shogun;
40 using namespace Eigen;
41 
42 namespace shogun
43 {
44 
46 {
47  init();
48 }
49 
51  CFeatures* feat, CMeanFunction* m, CLabels* lab, CLikelihoodModel* mod)
52  : CInference(kern, feat, m, lab, mod)
53 {
54  init();
55 }
56 
57 void CLaplaceInference::init()
58 {
59  SG_ADD(&m_dlp, "dlp", "derivative of log likelihood with respect to function location", MS_NOT_AVAILABLE);
60  SG_ADD(&m_mu, "mu", "mean vector of the approximation to the posterior", MS_NOT_AVAILABLE);
61  SG_ADD(&m_Sigma, "Sigma", "covariance matrix of the approximation to the posterior", MS_NOT_AVAILABLE);
62  SG_ADD(&m_W, "W", "the noise matrix", MS_NOT_AVAILABLE);
63 }
64 
66 {
67 }
68 
70 {
72 
73  if (!m_gradient_update)
74  {
76  update_deriv();
77  m_gradient_update=true;
79  }
80 }
82 {
83  SG_DEBUG("entering\n");
84 
86  update_alpha();
87  update_chol();
88  m_gradient_update=false;
90 
91  SG_DEBUG("leaving\n");
92 }
93 
95 {
97  update();
98 
100  return result;
101 
102 }
103 
105 {
107  update();
108 
109  return SGMatrix<float64_t>(m_L);
110 
111 }
112 
114 {
116 
118 }
119 
120 }
121 
virtual void update()
Definition: Inference.cpp:243
virtual void update_parameter_hash()
Definition: SGObject.cpp:282
SGVector< float64_t > m_mu
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
virtual void update_alpha()=0
virtual void update_chol()=0
Definition: SGMatrix.h:25
virtual SGMatrix< float64_t > get_posterior_covariance()
An abstract class of the mean function.
Definition: MeanFunction.h:49
virtual void update_deriv()=0
virtual void update_approx_cov()=0
virtual SGVector< float64_t > get_alpha()
virtual void compute_gradient()
Definition: Inference.cpp:270
SGVector< float64_t > m_dlp
SGMatrix< float64_t > m_L
Definition: Inference.h:482
virtual SGMatrix< float64_t > get_cholesky()
#define SG_DEBUG(...)
Definition: SGIO.h:106
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The Inference Method base class.
Definition: Inference.h:81
SGMatrix< float64_t > m_Sigma
The class Features is the base class of all feature objects.
Definition: Features.h:69
SGVector< float64_t > m_W
The Kernel base class.
#define SG_ADD(...)
Definition: SGObject.h:93
virtual bool parameter_hash_changed()
Definition: SGObject.cpp:296
The Likelihood model base class.
SGVector< float64_t > m_alpha
Definition: Inference.h:479

SHOGUN Machine Learning Toolbox - Documentation