本文整理汇总了C++中CKernel::get_parameter_gradient方法的典型用法代码示例。如果您正苦于以下问题:C++ CKernel::get_parameter_gradient方法的具体用法?C++ CKernel::get_parameter_gradient怎么用?C++ CKernel::get_parameter_gradient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKernel
的用法示例。
在下文中一共展示了CKernel::get_parameter_gradient方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}