本文整理汇总了C++中CKernel::get_kernel_matrix方法的典型用法代码示例。如果您正苦于以下问题:C++ CKernel::get_kernel_matrix方法的具体用法?C++ CKernel::get_kernel_matrix怎么用?C++ CKernel::get_kernel_matrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKernel
的用法示例。
在下文中一共展示了CKernel::get_kernel_matrix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update_kernel_matrices
void CGaussianProcessRegression::update_kernel_matrices()
{
CKernel* kernel = NULL;
if (m_method)
kernel = m_method->get_kernel();
if (kernel)
{
float64_t m_scale = m_method->get_scale();
CFeatures* latent_features = m_method->get_latent_features();
if (latent_features)
kernel->init(latent_features, m_data);
else
kernel->init(m_data, m_data);
//K(X_test, X_train)
m_k_trts = kernel->get_kernel_matrix();
for (index_t i = 0; i < m_k_trts.num_rows; i++)
{
for (index_t j = 0; j < m_k_trts.num_cols; j++)
m_k_trts(i,j) *= (m_scale*m_scale);
}
kernel->init(m_data, m_data);
m_k_tsts = kernel->get_kernel_matrix();
for (index_t i = 0; i < m_k_tsts.num_rows; i++)
{
for (index_t j = 0; j < m_k_tsts.num_cols; j++)
m_k_tsts(i,j) *= (m_scale*m_scale);
}
kernel->remove_lhs_and_rhs();
SG_UNREF(kernel);
SG_UNREF(latent_features);
}
}
示例2: update_kernel_matrices
void CGaussianProcessRegression::update_kernel_matrices()
{
CKernel* kernel = NULL;
if (m_method)
kernel = m_method->get_kernel();
if (kernel)
{
float64_t m_scale = m_method->get_scale();
kernel->cleanup();
kernel->init(m_features, m_data);
//K(X_test, X_train)
m_k_trts = kernel->get_kernel_matrix();
for (index_t i = 0; i < m_k_trts.num_rows; i++)
{
for (index_t j = 0; j < m_k_trts.num_cols; j++)
m_k_trts(i,j) *= (m_scale*m_scale);
}
kernel->cleanup();
kernel->init(m_data, m_data);
m_k_tsts = kernel->get_kernel_matrix();
for (index_t i = 0; i < m_k_tsts.num_rows; i++)
{
for (index_t j = 0; j < m_k_tsts.num_cols; j++)
m_k_tsts(i,j) *= (m_scale*m_scale);
}
SG_UNREF(kernel);
}
}
示例3: result
SGMatrix<float64_t> CCombinedKernel::get_parameter_gradient(TParameter* param,
CSGObject* obj, index_t index)
{
SGMatrix<float64_t> result(0,0);
if (strcmp(param->m_name, "combined_kernel_weight") == 0)
{
CListElement* current = NULL ;
CKernel* k = get_first_kernel(current);
if (append_subkernel_weights)
{
while(k)
{
result = k->get_parameter_gradient(param, obj, index);
SG_UNREF(k);
if (result.num_cols*result.num_rows > 0)
return result;
k = get_next_kernel(current);
}
}
else
{
while(k)
{
if(obj == k)
{
result = k->get_kernel_matrix();
SG_UNREF(k);
return result;
}
SG_UNREF(k);
k = get_next_kernel(current);
}
}
}
else
{
CListElement* current = NULL ;
CKernel* k = get_first_kernel(current);
float64_t coeff;
while(k)
{
SGMatrix<float64_t> derivative =
k->get_parameter_gradient(param, obj, index);
coeff = 1.0;
if (!append_subkernel_weights)
coeff = k->get_combined_kernel_weight();
for (index_t g = 0; g < derivative.num_rows; g++)
{
for (index_t h = 0; h < derivative.num_cols; h++)
derivative(g,h) *= coeff;
}
if (derivative.num_cols*derivative.num_rows > 0)
{
if (result.num_cols == 0 && result.num_rows == 0)
result = derivative;
else
{
for (index_t g = 0; g < derivative.num_rows; g++)
{
for (index_t h = 0; h < derivative.num_cols; h++)
result(g,h) += derivative(g,h);
}
}
}
SG_UNREF(k);
k = get_next_kernel(current);
}
}
return result;
}