SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
37 #include <shogun/lib/external/brent.h>
39 
40 using namespace shogun;
41 using namespace Eigen;
42 
43 namespace shogun
44 {
45 
47 {
48  init();
49 }
50 
52  CFeatures* feat, CMeanFunction* m, CLabels* lab, CLikelihoodModel* mod)
53  : CInference(kern, feat, m, lab, mod)
54 {
55  init();
56 }
57 
58 void CLaplaceInference::init()
59 {
60  SG_ADD(&m_dlp, "dlp", "derivative of log likelihood with respect to function location", MS_NOT_AVAILABLE);
61  SG_ADD(&m_mu, "mu", "mean vector of the approximation to the posterior", MS_NOT_AVAILABLE);
62  SG_ADD(&m_Sigma, "Sigma", "covariance matrix of the approximation to the posterior", MS_NOT_AVAILABLE);
63  SG_ADD(&m_W, "W", "the noise matrix", MS_NOT_AVAILABLE);
64 }
65 
67 {
68 }
69 
71 {
73 
74  if (!m_gradient_update)
75  {
77  update_deriv();
78  m_gradient_update=true;
80  }
81 }
83 {
84  SG_DEBUG("entering\n");
85 
87  update_alpha();
88  update_chol();
89  m_gradient_update=false;
91 
92  SG_DEBUG("leaving\n");
93 }
94 
96 {
98  update();
99 
101  return result;
102 
103 }
104 
106 {
108  update();
109 
110  return SGMatrix<float64_t>(m_L);
111 
112 }
113 
115 {
117 
119 }
120 
121 }
122 
virtual void update()
Definition: Inference.cpp:316
virtual void update_parameter_hash()
Definition: SGObject.cpp:281
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:20
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:343
SGVector< float64_t > m_dlp
SGMatrix< float64_t > m_L
Definition: Inference.h:487
virtual SGMatrix< float64_t > get_cholesky()
#define SG_DEBUG(...)
Definition: SGIO.h:107
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:68
SGVector< float64_t > m_W
The Kernel base class.
Definition: Kernel.h:159
#define SG_ADD(...)
Definition: SGObject.h:84
virtual bool parameter_hash_changed()
Definition: SGObject.cpp:295
The Likelihood model base class.
SGVector< float64_t > m_alpha
Definition: Inference.h:484

SHOGUN Machine Learning Toolbox - Documentation