46 using namespace Eigen;
60 void CVarDTCInferenceMethod::init()
119 SG_SERROR(
"Provided inference is not of type CVarDTCInferenceMethod!\n")
130 "VarDTC inference method can only use Gaussian likelihood function\n")
132 "of CRegressionLabels\n")
153 0.5*
m_yy/(
m_sigma2)-eigen_inv_La.diagonal().array().log().sum();
164 return neg_f012+neg_f3+neg_trk;
199 eigen_C=eigen_Knm_inv_Lm.transpose()*eigen_Knm_inv_Lm;
213 eigen_L=eigen_inv_Lm*(
215 )*eigen_inv_Lm.transpose();
219 -eigen_C.diagonal().array().sum());
235 VectorXd y_cor=eigen_y-eigen_m;
236 VectorXd eigen_y_Knm_inv_Lm_inv_La_transpose=eigen_inv_La.transpose()*(
237 eigen_Knm_inv_Lm.transpose()*y_cor);
241 eigen_alpha=eigen_inv_Lm*eigen_inv_La*eigen_y_Knm_inv_Lm_inv_La_transpose;
243 m_yy=y_cor.dot(y_cor);
245 m_f3=0.5*eigen_y_Knm_inv_Lm_inv_La_transpose.dot(eigen_y_Knm_inv_Lm_inv_La_transpose)/
m_sigma2;
275 MatrixXd Tmm=-eigen_L-eigen_alpha*eigen_alpha.transpose();
281 eigen_Tmm = Tmm - (eigen_inv_Lm*eigen_C*eigen_inv_Lm.transpose()/
m_sigma2);
289 eigen_Tnm += (eigen_y-eigen_m)*eigen_alpha.transpose();
309 REQUIRE(!strcmp(param->
m_name,
"log_sigma"),
"Can't compute derivative of "
310 "the nagative log marginal likelihood wrt %s.%s parameter\n",
321 float64_t sigma2aux=
m_sigma2*eigen_inv_La.cwiseProduct(eigen_inv_La).array().sum()+
349 for(int32_t lat_idx=0; lat_idx<eigen_Tnm.cols(); lat_idx++)
361 for(int32_t lat_lidx=0; lat_lidx<eigen_Tmm.cols(); lat_lidx++)
378 REQUIRE(param,
"Param not set\n");
379 REQUIRE(!strcmp(param->
m_name,
"log_inducing_noise"),
"Can't compute derivative of "
380 "the nagative log marginal likelihood wrt %s.%s parameter\n",
401 float64_t dkern= -0.5*eigen_dKuui.cwiseProduct(eigen_Tmm).sum()
402 -eigen_dKui.cwiseProduct(eigen_Tnm.transpose()).sum()/
m_sigma2
403 +0.5*eigen_ddiagKi.array().sum()/
m_sigma2;
410 REQUIRE(param,
"Param not set\n");
412 int64_t len=
const_cast<TParameter *
>(param)->m_datatype.get_num_elements();
430 *eigen_alpha+(eigen_m-eigen_y))/
m_sigma2;
437 SG_WARNING(
"The method does not require a minimizer. The provided minimizer will not be used.\n");
virtual const char * get_name() const =0
virtual bool init(CFeatures *lhs, CFeatures *rhs)
SGMatrix< float64_t > m_Tnm
virtual void compute_gradient()
virtual ELabelType get_label_type() const =0
virtual void update_parameter_hash()
virtual void update_chol()
Class that models Gaussian likelihood.
virtual SGVector< float64_t > get_derivative_wrt_inducing_noise(const TParameter *param)
Real Labels are real-valued labels.
virtual SGVector< float64_t > get_posterior_mean()
virtual void update_alpha()
virtual void update_deriv()
SGMatrix< float64_t > m_Tmm
The class Labels models labels, i.e. class assignments of objects.
virtual EInferenceType get_inference_type() const
real valued labels (e.g. for regression, classifier outputs)
The inference method class based on the Titsias' variational bound. For more details, see Titsias, Michalis K. "Variational learning of inducing variables in sparse Gaussian processes." International Conference on Artificial Intelligence and Statistics. 2009.
virtual float64_t get_derivative_related_cov(SGVector< float64_t > ddiagKi, SGMatrix< float64_t > dKuui, SGMatrix< float64_t > dKui)
virtual ELikelihoodModelType get_model_type() const
#define SG_NOTIMPLEMENTED
virtual SGVector< float64_t > get_mean_vector(const CFeatures *features) const =0
virtual SGVector< float64_t > get_diagonal_vector()
virtual SGVector< float64_t > get_derivative_wrt_mean(const TParameter *param)
An abstract class of the mean function.
virtual void check_members() const
The sparse inference base class for classification and regression for 1-D labels (1D regression and b...
virtual SGVector< float64_t > get_derivative_wrt_likelihood_model(const TParameter *param)
static CVarDTCInferenceMethod * obtain_from_generic(CInference *inference)
virtual void compute_gradient()
virtual CFeatures * get_inducing_features()
SGMatrix< float64_t > m_kuu
SGMatrix< float64_t > m_L
SGMatrix< float64_t > m_Knm_inv_Lm
virtual SGMatrix< float64_t > get_posterior_covariance()
SGVector< float64_t > m_ktrtr_diag
static CGaussianLikelihood * obtain_from_generic(CLikelihoodModel *lik)
SGMatrix< float64_t > m_inv_Lm
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
The Inference Method base class.
SGMatrix< float64_t > m_inv_La
SGMatrix< float64_t > m_inducing_features
The class Features is the base class of all feature objects.
static float64_t exp(float64_t x)
virtual SGMatrix< float64_t > get_parameter_gradient(const TParameter *param, index_t index=-1)
virtual void check_members() const
virtual const char * get_name() const
static float64_t log(float64_t v)
SGMatrix< float64_t > m_ktru
virtual SGVector< float64_t > get_derivative_wrt_inducing_features(const TParameter *param)
The minimizer base class.
virtual float64_t get_negative_log_marginal_likelihood()
CLikelihoodModel * m_model
virtual bool parameter_hash_changed()
The Likelihood model base class.
virtual ~CVarDTCInferenceMethod()
float64_t m_log_ind_noise
virtual void register_minimizer(Minimizer *minimizer)
SGVector< float64_t > m_alpha
static const float64_t PI