Skip to content

Commit

Permalink
update the EP inference
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkerlin committed May 5, 2015
1 parent 7e52491 commit 92a2346
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
22 changes: 16 additions & 6 deletions src/shogun/machine/gp/EPInferenceMethod.cpp
Expand Up @@ -111,20 +111,31 @@ SGVector<float64_t> CEPInferenceMethod::get_diagonal_vector()

SGVector<float64_t> CEPInferenceMethod::get_posterior_mean()
{
if (parameter_hash_changed())
update();
compute_gradient();

return SGVector<float64_t>(m_mu);
}

SGMatrix<float64_t> CEPInferenceMethod::get_posterior_covariance()
{
if (parameter_hash_changed())
update();
compute_gradient();

return SGMatrix<float64_t>(m_Sigma);
}

void CEPInferenceMethod::compute_gradient()
{
CInferenceMethod::compute_gradient();

if (!m_gradient_update)
{
// update matrices to compute derivatives
update_deriv();
m_gradient_update=true;
update_parameter_hash();
}
}

void CEPInferenceMethod::update()
{
SG_DEBUG("entering\n");
Expand Down Expand Up @@ -269,8 +280,7 @@ void CEPInferenceMethod::update()
// update vector alpha
update_alpha();

// update matrices to compute derivatives
update_deriv();
m_gradient_update=false;

// update hash of the parameters
update_parameter_hash();
Expand Down
5 changes: 4 additions & 1 deletion src/shogun/machine/gp/EPInferenceMethod.h
Expand Up @@ -224,10 +224,13 @@ class CEPInferenceMethod : public CInferenceMethod
return m_model->supports_binary();
}

/** update data all matrices */
/** update all matrices Expect gradients*/
virtual void update();

protected:
/** update gradients */
virtual void compute_gradient();

/** update alpha matrix */
virtual void update_alpha();

Expand Down

0 comments on commit 92a2346

Please sign in to comment.