Skip to content

Commit

Permalink
Added checking for empty features in InferenceMethod and ExactInferen…
Browse files Browse the repository at this point in the history
…ceMethod.
  • Loading branch information
puffin444 committed Jul 7, 2012
1 parent 79cfd56 commit 864211e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
35 changes: 22 additions & 13 deletions src/shogun/regression/gp/ExactInferenceMethod.cpp
Expand Up @@ -26,19 +26,15 @@ using namespace shogun;

CExactInferenceMethod::CExactInferenceMethod() : CInferenceMethod()
{
update_train_kernel();
update_chol();
update_alpha();
update_all();
update_parameter_hash();
}

CExactInferenceMethod::CExactInferenceMethod(CKernel* kern, CDotFeatures* feat,
CMeanFunction* m, CLabels* lab, CLikelihoodModel* mod) :
CInferenceMethod(kern, feat, m, lab, mod)
{
update_train_kernel();
update_chol();
update_alpha();
update_all();
update_parameter_hash();
}

Expand All @@ -48,16 +44,29 @@ CExactInferenceMethod::~CExactInferenceMethod()

void CExactInferenceMethod::update_all()
{
m_label_vector =
((CRegressionLabels*) m_labels)->get_labels().clone();

m_feature_matrix =
m_features->get_computed_dot_feature_matrix();
if (m_labels)
{
m_label_vector =
((CRegressionLabels*) m_labels)->
get_labels().clone();
}

if (m_features && m_features->get_num_vectors())
{
m_feature_matrix =
m_features->get_computed_dot_feature_matrix();

update_data_means();
update_train_kernel();
update_chol();
update_alpha();

if (m_kernel)
update_train_kernel();
if (m_ktrtr.num_cols && m_ktrtr.num_rows)
{
update_chol();
update_alpha();
}
}
}

void CExactInferenceMethod::check_members()
Expand Down
15 changes: 11 additions & 4 deletions src/shogun/regression/gp/InferenceMethod.cpp
Expand Up @@ -68,8 +68,11 @@ void CInferenceMethod::set_features(CDotFeatures* feat)
SG_UNREF(m_features);
m_features=feat;

m_feature_matrix =
m_features->get_computed_dot_feature_matrix();
if (m_features && m_features->get_num_vectors())
{
m_feature_matrix =
m_features->get_computed_dot_feature_matrix();
}

update_data_means();
update_train_kernel();
Expand Down Expand Up @@ -104,8 +107,12 @@ void CInferenceMethod::set_labels(CLabels* lab)
SG_UNREF(m_labels);
m_labels = lab;

m_label_vector =
((CRegressionLabels*) m_labels)->get_labels().clone();
if (m_labels)
{
m_label_vector =
((CRegressionLabels*) m_labels)->
get_labels().clone();
}

update_data_means();
update_alpha();
Expand Down

0 comments on commit 864211e

Please sign in to comment.