50 using namespace Eigen;
67 void CKLApproxDiagonalInferenceMethod::init()
81 SG_SERROR(
"Provided inference is not of type CKLApproxDiagonalInferenceMethod!\n")
105 eigen_result=eigen_alpha;
127 eigen_s2=eigen_log_v.array().exp();
137 "The length of gradients (%d) should the same as the length of parameters (%d)\n",
163 eigen_dnlz_log_v=(eigen_InvK.diagonal().array()-(1.0/eigen_s2.array()));
164 eigen_dnlz_log_v=(0.5*eigen_dnlz_log_v.array())-eigen_dv.array();
165 eigen_dnlz_log_v=eigen_dnlz_log_v.array()*eigen_s2.array();
183 float64_t trace=(eigen_s2.array()*eigen_InvK.diagonal().array()).sum();
186 float64_t result=-a+0.5*(-eigen_K.rows()+eigen_alpha.dot(eigen_mu-eigen_mean)+trace-log_det);
214 float64_t trace=eigen_InvK.diagonal().array().sum();
217 if (nlml_new<=nlml_def)
221 if (
m_alpha.
vlen != total_len || nlml_def<nlml_new)
239 eigen_Sigma=eigen_s2.asDiagonal();
virtual bool set_variational_distribution(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab)
SGVector< float64_t > m_alpha
The Inference Method base class.
virtual SGVector< float64_t > get_variational_first_derivative(const TParameter *param) const =0
virtual float64_t get_negative_log_marginal_likelihood_helper()
The class Labels models labels, i.e. class assignments of objects.
virtual int32_t get_num_labels() const =0
The variational Gaussian Likelihood base class. The variational distribution is Gaussian.
TParameter * get_parameter(int32_t idx)
CKLApproxDiagonalInferenceMethod()
Eigen::MatrixXd solve_inverse(Eigen::MatrixXd A)
An abstract class of the mean function.
virtual SGVector< float64_t > get_alpha()
static CKLApproxDiagonalInferenceMethod * obtain_from_generic(CInferenceMethod *inference)
virtual void get_gradient_of_nlml_wrt_parameters(SGVector< float64_t > gradient)
SGMatrix< float64_t > m_Sigma
The KL approximation inference method class.
virtual float64_t lbfgs_optimization()
virtual bool lbfgs_precompute()
virtual void update_alpha()
static T sum(T *vec, int32_t len)
Return sum(vec)
virtual SGVector< float64_t > get_variational_expection()=0
The KL approximation inference method class.
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
static float64_t exp(float64_t x)
SGVector< float64_t > m_mu
SGVector< float64_t > m_s2
SGMatrix< float64_t > m_InvK_Sigma
virtual EInferenceType get_inference_type() const
virtual CVariationalGaussianLikelihood * get_variational_likelihood() const
virtual void update_Sigma()
SGVector< float64_t > m_mean_vec
virtual bool parameter_hash_changed()
float64_t m_log_det_Kernel
The Likelihood model base class.
SGMatrix< float64_t > m_ktrtr
virtual ~CKLApproxDiagonalInferenceMethod()
virtual void update_InvK_Sigma()