40 using namespace Eigen;
44 CSingleFITCLaplacianInferenceMethodWithLBFGS::CSingleFITCLaplacianInferenceMethodWithLBFGS()
59 bool enable_newton_if_fail)
61 m_enable_newton_if_fail = enable_newton_if_fail;
79 int orthantwise_start,
83 m_max_linesearch = max_linesearch;
84 m_linesearch = linesearch;
85 m_max_iterations = max_iterations;
89 m_min_step = min_step;
90 m_max_step = max_step;
95 m_orthantwise_c = orthantwise_c;
96 m_orthantwise_start = orthantwise_start;
97 m_orthantwise_end = orthantwise_end;
100 void CSingleFITCLaplacianInferenceMethodWithLBFGS::init()
106 "The number of corrections to approximate the inverse hessian matrix",
108 SG_ADD(&m_max_linesearch,
"max_linesearch",
109 "The maximum number of trials to do line search for each L-BFGS update",
111 SG_ADD(&m_linesearch,
"linesearch",
112 "The line search algorithm",
114 SG_ADD(&m_max_iterations,
"max_iterations",
115 "The maximum number of iterations for L-BFGS update",
118 "Delta for convergence test based on the change of function value",
121 "Distance for delta-based convergence test",
123 SG_ADD(&m_epsilon,
"epsilon",
124 "Epsilon for convergence test based on the change of gradient",
126 SG_ADD(&m_min_step,
"min_step",
127 "The minimum step of the line search",
129 SG_ADD(&m_max_step,
"max_step",
130 "The maximum step of the line search",
133 "A parameter used in Armijo condition",
136 "A parameter used in curvature condition",
139 "A parameter used in Morethuente linesearch to control the accuracy",
142 "The machine precision for floating-point values",
144 SG_ADD(&m_orthantwise_c,
"orthantwise_c",
145 "Coeefficient for the L1 norm of variables",
147 SG_ADD(&m_orthantwise_start,
"orthantwise_start",
148 "Start index for computing L1 norm of the variables",
150 SG_ADD(&m_orthantwise_end,
"orthantwise_end",
151 "End index for computing L1 norm of the variables",
153 SG_ADD(&m_enable_newton_if_fail,
"enable_newton_if_fail",
154 "Enable the original Newton method if the L-BFGS method fails",
162 float64_t CSingleFITCLaplacianInferenceMethodWithLBFGS::evaluate(
179 obj_prt->get_psi_wrt_alpha(alpha_cast, dim, psi);
180 obj_prt->get_gradient_wrt_alpha(alpha_cast, gradient, dim);
202 lbfgs_param.
delta = m_delta;
203 lbfgs_param.
past = m_past;
204 lbfgs_param.
epsilon = m_epsilon;
207 lbfgs_param.
ftol = m_ftol;
208 lbfgs_param.
wolfe = m_wolfe;
209 lbfgs_param.
gtol = m_gtol;
210 lbfgs_param.
xtol = m_xtol;
227 void * obj_prt =
static_cast<void *
>(
this);
230 CSingleFITCLaplacianInferenceMethodWithLBFGS::evaluate,
231 NULL, obj_prt, &lbfgs_param);
244 SG_WARNING(
"Error during L-BFGS optimization, using original Newton method as fallback\n");
251 eigen_mu=eigen_tmp+eigen_mean_f;
258 eigen_post_alpha=eigen_R0.transpose()*(eigen_V*eigen_alpha);
261 void CSingleFITCLaplacianInferenceMethodWithLBFGS::get_psi_wrt_alpha(
276 eigen_f=eigen_tmp+eigen_mean_f;
279 psi=eigen_alpha.dot(eigen_tmp) * 0.5;
283 void CSingleFITCLaplacianInferenceMethodWithLBFGS::get_gradient_wrt_alpha(
291 SGVector<float64_t> f(dim);
300 SGVector<float64_t> al(alpha, dim,
false);
303 eigen_f=eigen_tmp+eigen_mean_f;
305 SGVector<float64_t> dlp_f =
311 SGVector<float64_t> tmp2(al.vlen);
313 eigen_tmp2=eigen_alpha-eigen_dlp_f;
316 eigen_gradient=eigen_tmp3;
virtual SGVector< float64_t > get_log_probability_f(const CLabels *lab, SGVector< float64_t > func) const =0
The Laplace approximation FITC inference method with LBFGS class for regression and binary classifica...
SGVector< float64_t > m_alpha
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 class Labels models labels, i.e. class assignments of objects.
SGVector< float64_t > m_al
virtual SGVector< float64_t > get_mean_vector(const CFeatures *features) const =0
The SingleFITCLaplace approximation inference method class for regression and binary Classification...
An abstract class of the mean function.
SGVector< float64_t > m_mu
virtual SGVector< float64_t > compute_mvmK(SGVector< float64_t > al)
virtual void update_alpha()
static const float64_t epsilon
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 ~CSingleFITCLaplacianInferenceMethodWithLBFGS()
static T sum(T *vec, int32_t len)
Return sum(vec)
virtual void update_alpha()
CSingleFITCLaplacianInferenceMethodWithLBFGS()
all of classes and functions are contained in the shogun namespace
SGMatrix< float64_t > m_chol_R0
The class Features is the base class of all feature objects.
virtual SGVector< float64_t > get_log_probability_derivative_f(const CLabels *lab, SGVector< float64_t > func, index_t i) const =0
SGMatrix< float64_t > m_V
The Likelihood model base class.
SGMatrix< float64_t > m_ktrtr
CLikelihoodModel * m_model
virtual void set_newton_method(bool enable_newton_if_fail)