Skip to content

Commit

Permalink
Merge pull request #1346 from votjakovr/feature/gp_refactoring
Browse files Browse the repository at this point in the history
Move common methods from drived classes of inference methods to base class
  • Loading branch information
karlnapf committed Aug 1, 2013
2 parents 5caa7db + f6b5c23 commit ca5c973
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 70 deletions.
22 changes: 0 additions & 22 deletions src/shogun/machine/gp/ExactInferenceMethod.h
Expand Up @@ -146,28 +146,6 @@ class CExactInferenceMethod: public CInferenceMethod
*/
virtual SGVector<float64_t> get_diagonal_vector();

/** get the gradient
*
* @return map of gradient: keys are names of parameters, values
* are values of derivative with respect to that parameter.
*/
virtual CMap<TParameter*, SGVector<float64_t> > get_gradient(
CMap<TParameter*, CSGObject*>& para_dict)
{
return get_marginal_likelihood_derivatives(para_dict);
}

/** get the function value
*
* @return vector that represents the function value
*/
virtual SGVector<float64_t> get_quantity()
{
SGVector<float64_t> result(1);
result[0] = get_negative_marginal_likelihood();
return result;
}

/**
* @return whether combination of exact inference method and given
* likelihood function supports regression
Expand Down
22 changes: 0 additions & 22 deletions src/shogun/machine/gp/FITCInferenceMethod.h
Expand Up @@ -164,28 +164,6 @@ class CFITCInferenceMethod: public CInferenceMethod
*/
virtual SGVector<float64_t> get_diagonal_vector();

/** get the gradient
*
* @return map of gradient: keys are names of parameters, values
* are values of derivative with respect to that parameter.
*/
virtual CMap<TParameter*, SGVector<float64_t> > get_gradient(
CMap<TParameter*, CSGObject*>& para_dict)
{
return get_marginal_likelihood_derivatives(para_dict);
}

/** get the function value
*
* @return vector that represents the function value
*/
virtual SGVector<float64_t> get_quantity()
{
SGVector<float64_t> result(1);
result[0] = get_negative_marginal_likelihood();
return result;
}

/**
* @return whether combination of FITC inference method and given
* likelihood function supports regression
Expand Down
22 changes: 22 additions & 0 deletions src/shogun/machine/gp/InferenceMethod.h
Expand Up @@ -133,6 +133,28 @@ class CInferenceMethod : public CDifferentiableFunction
*/
virtual SGVector<float64_t> get_diagonal_vector()=0;

/** get the gradient
*
* @return map of gradient: keys are names of parameters, values
* are values of derivative with respect to that parameter.
*/
virtual CMap<TParameter*, SGVector<float64_t> > get_gradient(
CMap<TParameter*, CSGObject*>& para_dict)
{
return get_marginal_likelihood_derivatives(para_dict);
}

/** get the function value
*
* @return vector that represents the function value
*/
virtual SGVector<float64_t> get_quantity()
{
SGVector<float64_t> result(1);
result[0]=get_negative_marginal_likelihood();
return result;
}

/** returns mean vector \f$\mu\f$ of the Gaussian distribution
* \f$N(\mu,\Sigma)\f$, which is an approximation to the
* posterior:
Expand Down
30 changes: 4 additions & 26 deletions src/shogun/machine/gp/LaplacianInferenceMethod.h
Expand Up @@ -173,28 +173,6 @@ class CLaplacianInferenceMethod: public CInferenceMethod
*/
virtual SGMatrix<float64_t> get_posterior_approximation_covariance();

/** get the gradient
*
* @return map of gradient: keys are names of parameters, values
* are values of derivative with respect to that parameter.
*/
virtual CMap<TParameter*, SGVector<float64_t> > get_gradient(
CMap<TParameter*, CSGObject*>& para_dict)
{
return get_marginal_likelihood_derivatives(para_dict);
}

/** get the function value
*
* @return vector that represents the function value
*/
virtual SGVector<float64_t> get_quantity()
{
SGVector<float64_t> result(1);
result[0] = get_negative_marginal_likelihood();
return result;
}

/** get tolerance for newton iterations
*
* @return tolerance for newton iterations
Expand Down Expand Up @@ -231,15 +209,15 @@ class CLaplacianInferenceMethod: public CInferenceMethod
*/
virtual void set_minimization_tolerance(float64_t tol) { m_opt_tolerance=tol; }

/** get max for Brent's minimization method
/** get maximum for Brent's minimization method
*
* @return max for Brent's minimization method
* @return maximum for Brent's minimization method
*/
virtual float64_t get_minimization_max() { return m_opt_max; }

/** set max for Brent's minimization method
/** set maximum for Brent's minimization method
*
* @param iter max for Brent's minimization method
* @param max maximum for Brent's minimization method
*/
virtual void set_minimization_max(float64_t max) { m_opt_max=max; }

Expand Down

0 comments on commit ca5c973

Please sign in to comment.