39 using namespace Eigen;
59 REQUIRE(mod,
"the likelihood model must not be NULL\n")
62 "The provided likelihood model (%s) must support variational Gaussian inference. ",
63 "Please use a Variational Gaussian Likelihood model\n",
73 void CKLInferenceMethod::init()
80 "The noise factor used for correcting Kernel matrix",
83 "The exponential factor used for increasing noise_factor",
86 "The max number of attempt to correct Kernel matrix",
89 "The minimum coeefficient of kernel matrix in LDLT factorization used to check whether the kernel matrix is positive definite or not",
94 "The number of corrections to approximate the inverse Hessian matrix",
97 "The maximum number of trials to do line search for each L-BFGS update",
100 "The line search algorithm",
103 "The maximum number of iterations for L-BFGS update",
106 "Delta for convergence test based on the change of function value",
109 "Distance for delta-based convergence test",
112 "Epsilon for convergence test based on the change of gradient",
115 "The minimum step of the line search",
118 "The maximum step of the line search",
121 "A parameter used in Armijo condition",
124 "A parameter used in curvature condition",
127 "A parameter used in Morethuente linesearch to control the accuracy",
130 "The machine precision for floating-point values",
133 "Coeefficient for the L1 norm of variables",
136 "Start index for computing L1 norm of the variables",
139 "End index for computing L1 norm of the variables",
142 "Variational parameter sigma2",
145 "Variational parameter mu and posterior mean",
148 "Posterior covariance matrix Sigma",
185 REQUIRE(noise_factor>=0,
"The noise_factor %.20f should be non-negative\n", noise_factor);
191 REQUIRE(min_coeff_kernel>=0,
"The min_coeff_kernel %.20f should be non-negative\n", min_coeff_kernel);
197 REQUIRE(max_attempt>=0,
"The max_attempt %d should be non-negative. 0 means inifity attempts\n", max_attempt);
203 REQUIRE(exp_factor>1.0,
"The exp_factor %f should be greater than 1.0.\n", exp_factor);
228 SG_ERROR(
"The Kernel matrix is highly non-positive definite since the min_coeff_kernel is less than %.20f",
229 " even when adding %.20f noise to the diagonal elements at max %d attempts\n",
237 Kernel_D=ldlt.vectorD();
265 REQUIRE(obj_prt,
"The instance object passed to L-BFGS optimizer should not be NULL\n");
308 int orthantwise_start,
348 result[0]=-eigen_lp_dhyp.sum();
358 REQUIRE(param,
"Param not set\n");
360 int64_t len=
const_cast<TParameter *
>(param)->m_datatype.get_num_elements();
376 result[i]=-eigen_alpha.dot(eigen_dmu);
403 void * obj_prt =
static_cast<void *
>(
this);
405 CKLInferenceMethod::evaluate,
406 NULL, obj_prt, &lbfgs_param);
413 REQUIRE(!strcmp(param->
m_name,
"log_scale"),
"Can't compute derivative of "
414 "the nagative log marginal likelihood wrt %s.%s parameter\n",
429 REQUIRE(param,
"Param not set\n");
431 int64_t len=
const_cast<TParameter *
>(param)->m_datatype.get_num_elements();
virtual void set_lbfgs_parameters(int m=100, int max_linesearch=1000, int linesearch=LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE, int max_iterations=1000, float64_t delta=0.0, int past=0, float64_t epsilon=1e-5, float64_t min_step=1e-20, float64_t max_step=1e+20, float64_t ftol=1e-4, float64_t wolfe=0.9, float64_t gtol=0.9, float64_t xtol=1e-16, float64_t orthantwise_c=0.0, int orthantwise_start=0, int orthantwise_end=1)
virtual const char * get_name() const =0
virtual void set_model(CLikelihoodModel *mod)
float64_t m_orthantwise_c
virtual bool set_variational_distribution(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab)
virtual void update_parameter_hash()
virtual SGVector< float64_t > get_derivative_wrt_likelihood_model(const TParameter *param)
virtual void update_alpha()=0
SGVector< float64_t > m_alpha
virtual SGMatrix< float64_t > get_cholesky()
virtual SGVector< float64_t > get_first_derivative_wrt_hyperparameter(const TParameter *param) const =0
int32_t lbfgs(int32_t n, float64_t *x, float64_t *ptr_fx, lbfgs_evaluate_t proc_evaluate, lbfgs_progress_t proc_progress, void *instance, lbfgs_parameter_t *_param, lbfgs_adjust_step_t proc_adjust_step)
The Inference Method base class.
virtual void set_exp_factor(float64_t exp_factor)
The class Labels models labels, i.e. class assignments of objects.
The variational Gaussian Likelihood base class. The variational distribution is Gaussian.
virtual void update_init()
virtual void update_approx_cov()=0
virtual SGVector< float64_t > get_derivative_wrt_mean(const TParameter *param)
virtual bool lbfgs_precompute()=0
An abstract class of the mean function.
virtual const char * get_name() const
static const float64_t epsilon
SGMatrix< float64_t > m_Sigma
float64_t m_min_coeff_kernel
SGMatrix< float64_t > m_L
virtual float64_t get_negative_log_marginal_likelihood()
virtual void set_min_coeff_kernel(float64_t min_coeff_kernel)
virtual void check_variational_likelihood(CLikelihoodModel *mod) const
virtual void compute_gradient()
virtual float64_t lbfgs_optimization()
virtual SGVector< float64_t > get_derivative_wrt_inference_method(const TParameter *param)
virtual void set_max_attempt(index_t max_attempt)
virtual SGVector< float64_t > get_posterior_mean()
virtual float64_t get_derivative_related_cov(SGMatrix< float64_t > dK)=0
virtual SGMatrix< float64_t > get_posterior_covariance()
virtual Eigen::LDLT< Eigen::MatrixXd, 0x1 > update_init_helper()
The KL approximation inference method class.
virtual float64_t get_nlml_wrt_parameters()
virtual SGVector< float64_t > get_parameter_derivative(const CFeatures *features, const TParameter *param, index_t index=-1)
all of classes and functions are contained in the shogun namespace
virtual void set_noise_factor(float64_t noise_factor)
virtual SGVector< float64_t > get_derivative_wrt_kernel(const TParameter *param)
The class Features is the base class of all feature objects.
virtual void update_chol()=0
static float64_t exp(float64_t x)
virtual SGMatrix< float64_t > get_parameter_gradient(const TParameter *param, index_t index=-1)
The Variational Likelihood base class.
SGVector< float64_t > m_mu
SGVector< float64_t > m_s2
virtual void get_gradient_of_nlml_wrt_parameters(SGVector< float64_t > gradient)=0
virtual CVariationalGaussianLikelihood * get_variational_likelihood() const
virtual bool supports_derivative_wrt_hyperparameter() const =0
virtual void update_deriv()=0
virtual ~CKLInferenceMethod()
virtual void set_model(CLikelihoodModel *mod)
virtual bool parameter_hash_changed()
The Likelihood model base class.
SGMatrix< float64_t > m_ktrtr
virtual float64_t get_negative_log_marginal_likelihood_helper()=0
virtual void compute_gradient()
static const float64_t NOT_A_NUMBER
not a number
CLikelihoodModel * m_model