Skip to content

Commit

Permalink
Merge pull request #2795 from yorkerlin/develop
Browse files Browse the repository at this point in the history
update the comments
  • Loading branch information
karlnapf committed Apr 7, 2015
2 parents d65b1e7 + 58afde5 commit 41ae359
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/shogun/machine/gp/FITCInferenceMethod.h
Expand Up @@ -44,7 +44,8 @@ namespace shogun
*
* Warning: the time complexity of method,
* CSingleFITCLaplacianBase::get_derivative_wrt_kernel(const TParameter* param),
* depends on the implementation of kernel method, get_parameter_gradient_diagonal(param, i).
* depends on the implementation of virtual kernel method,
* CKernel::get_parameter_gradient_diagonal(param, i).
* The default time complexity of the kernel method can be O(n^2)
*
* Warning: the the time complexity increases from O(m^2*n) to O(n^2*m) if method
Expand Down
4 changes: 4 additions & 0 deletions src/shogun/machine/gp/MultiLaplacianInferenceMethod.cpp
Expand Up @@ -362,6 +362,10 @@ void CMultiLaplacianInferenceMethod::update_alpha()
m_nlz+=Psi_New;
}

if (Psi_Old-Psi_New>m_tolerance && iter>=m_iter)
{
SG_WARNING("Max iterations (%d) reached, but convergence level (%f) is not yet below tolerance (%f)\n", m_iter, Psi_Old-Psi_New, m_tolerance);
}
}

void CMultiLaplacianInferenceMethod::update_deriv()
Expand Down
18 changes: 10 additions & 8 deletions src/shogun/machine/gp/SingleFITCLaplacianBase.h
Expand Up @@ -60,8 +60,10 @@ namespace shogun
* This specific implementation was inspired by the infFITC.m and infFITC_Laplace.m file
* in the GPML toolbox.
*
* Warning: the time complexity of method, get_derivative_wrt_kernel(const TParameter* param),
* depends on the implementation of kernel method, get_parameter_gradient_diagonal(param, i).
* Warning: the time complexity of method,
* CSingleFITCLaplacianBase::get_derivative_wrt_kernel(const TParameter* param),
* depends on the implementation of virtual kernel method,
* CKernel::get_parameter_gradient_diagonal(param, i).
* The default time complexity of the kernel method can be O(n^2)
*
*/
Expand Down Expand Up @@ -108,7 +110,7 @@ class CSingleFITCLaplacianBase: public CFITCInferenceBase
*/
virtual void check_fully_FITC();

/** compute matrices which are required to compute negative log marginal
/** compute variables which are required to compute negative log marginal
* likelihood full derivatives wrt cov-like hyperparameter \f$\theta\f$
*
* Note that
Expand All @@ -124,7 +126,7 @@ class CSingleFITCLaplacianBase: public CFITCInferenceBase
virtual float64_t get_derivative_related_cov(SGVector<float64_t> ddiagKi,
SGMatrix<float64_t> dKuui, SGMatrix<float64_t> dKui);

/** compute matrices which are required to compute negative log marginal
/** compute variables which are required to compute negative log marginal
* likelihood derivatives wrt cov-like hyperparameter \f$\theta\f$
*
* Note that
Expand All @@ -143,7 +145,7 @@ class CSingleFITCLaplacianBase: public CFITCInferenceBase
SGMatrix<float64_t> dKuui, SGMatrix<float64_t> dKui,
SGVector<float64_t> v, SGMatrix<float64_t> R);

/** helper function to compute matrices which are required to compute negative log marginal
/** helper function to compute variables which are required to compute negative log marginal
* likelihood derivatives wrt cov-like hyperparameter \f$\theta\f$
*
* Note that
Expand All @@ -169,22 +171,22 @@ class CSingleFITCLaplacianBase: public CFITCInferenceBase
virtual SGVector<float64_t> get_derivative_wrt_inducing_noise(
const TParameter* param);

/** helper function to compute matrices which are required to compute negative log marginal
/** helper function to compute variables which are required to compute negative log marginal
* likelihood derivatives wrt the diagonal part of cov-like hyperparameter \f$\theta\f$
*
* @return derivative of negative log marginal likelihood
*/
virtual SGVector<float64_t> get_derivative_related_cov_diagonal();

/** helper function to compute matrices which are required to compute negative log marginal
/** helper function to compute variables which are required to compute negative log marginal
* likelihood derivatives wrt mean \f$\lambda\f$
*
* @param dmu \f$\frac{\partial {\mu_{n}}}{\partial {\lambda}}\f$
* @return derivative of negative log marginal likelihood
*/
virtual float64_t get_derivative_related_mean(SGVector<float64_t> dmu);

/** helper function to compute matrices which are required to compute negative log marginal
/** helper function to compute variables which are required to compute negative log marginal
* likelihood derivatives wrt inducing features
*
* Note that the kernel must support to compute the derivatives wrt inducing features
Expand Down
9 changes: 8 additions & 1 deletion src/shogun/machine/gp/SingleFITCLaplacianInferenceMethod.cpp
Expand Up @@ -426,6 +426,11 @@ void CSingleFITCLaplacianInferenceMethod::update_alpha()
Psi_New=local_min(0, m_opt_max, m_opt_tolerance, func, x);
}

if (Psi_Old-Psi_New>m_tolerance && iter>=m_iter)
{
SG_WARNING("Max iterations (%d) reached, but convergence level (%f) is not yet below tolerance (%f)\n", m_iter, Psi_Old-Psi_New, m_tolerance);
}

// compute f = K * alpha + m
SGVector<float64_t> tmp=compute_mvmK(m_al);
Map<VectorXd> eigen_tmp(tmp.vector, tmp.vlen);
Expand Down Expand Up @@ -614,6 +619,7 @@ float64_t CSingleFITCLaplacianInferenceMethod::get_derivative_related_cov(SGVect
SGVector<float64_t> CSingleFITCLaplacianInferenceMethod::get_derivative_wrt_inference_method(
const TParameter* param)
{
REQUIRE(param, "Param not set\n");
//time complexity O(m^2*n)
REQUIRE(!(strcmp(param->m_name, "scale")
&& strcmp(param->m_name, "inducing_noise")
Expand Down Expand Up @@ -803,7 +809,8 @@ SGVector<float64_t> CSingleFITCLaplacianInferenceMethod::get_derivative_wrt_mean
SGVector<float64_t> CSingleFITCLaplacianInferenceMethod::derivative_helper_when_Wneg(
SGVector<float64_t> res, const TParameter *param)
{
SG_WARNING("Derivative wrt %s cannot be computed since W is too negative\n", param->m_name);
REQUIRE(param, "Param not set\n");
SG_WARNING("Derivative wrt %s cannot be computed since W (the Hessian (diagonal) matrix) is too negative\n", param->m_name);
//dnlZ = struct('cov',0*hyp.cov, 'mean',0*hyp.mean, 'lik',0*hyp.lik);
res.zero();
return res;
Expand Down
5 changes: 5 additions & 0 deletions src/shogun/machine/gp/SingleLaplacianInferenceMethod.cpp
Expand Up @@ -383,6 +383,11 @@ void CSingleLaplacianInferenceMethod::update_alpha()
Psi_New=local_min(0, m_opt_max, m_opt_tolerance, func, x);
}

if (Psi_Old-Psi_New>m_tolerance && iter>=m_iter)
{
SG_WARNING("Max iterations (%d) reached, but convergence level (%f) is not yet below tolerance (%f)\n", m_iter, Psi_Old-Psi_New, m_tolerance);
}

// compute f = K * alpha + m
eigen_mu=eigen_ktrtr*CMath::sq(m_scale)*eigen_alpha+eigen_mean;
}
Expand Down

0 comments on commit 41ae359

Please sign in to comment.