本文整理汇总了C++中CKernel::get_kernel_row方法的典型用法代码示例。如果您正苦于以下问题:C++ CKernel::get_kernel_row方法的具体用法?C++ CKernel::get_kernel_row怎么用?C++ CKernel::get_kernel_row使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKernel
的用法示例。
在下文中一共展示了CKernel::get_kernel_row方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update_linear_component_mkl
void CSVRLight::update_linear_component_mkl(
int32_t* docs, int32_t* label, int32_t *active2dnum, float64_t *a,
float64_t *a_old, int32_t *working2dnum, int32_t totdoc, float64_t *lin,
float64_t *aicache, float64_t* c)
{
int32_t num = totdoc;
int32_t num_weights = -1;
int32_t num_kernels = kernel->get_num_subkernels() ;
const float64_t* old_beta = kernel->get_subkernel_weights(num_weights);
ASSERT(num_weights==num_kernels);
if ((kernel->get_kernel_type()==K_COMBINED) &&
(!((CCombinedKernel*)kernel)->get_append_subkernel_weights()))// for combined kernel
{
CCombinedKernel* k = (CCombinedKernel*) kernel;
CKernel* kn = k->get_first_kernel() ;
int32_t n = 0, i, j ;
while (kn!=NULL)
{
for(i=0;i<num;i++)
{
if(a[i] != a_old[i])
{
kn->get_kernel_row(i,NULL,aicache, true);
for(j=0;j<num;j++)
W[j*num_kernels+n]+=(a[i]-a_old[i])*aicache[regression_fix_index(j)]*(float64_t)label[i];
}
}
SG_UNREF(kn);
kn = k->get_next_kernel();
n++ ;
}
}
else // hope the kernel is fast ...
{
float64_t* w_backup = SG_MALLOC(float64_t, num_kernels);
float64_t* w1 = SG_MALLOC(float64_t, num_kernels);
// backup and set to zero
for (int32_t i=0; i<num_kernels; i++)
{
w_backup[i] = old_beta[i] ;
w1[i]=0.0 ;
}
for (int32_t n=0; n<num_kernels; n++)
{
w1[n]=1.0 ;
kernel->set_subkernel_weights(SGVector<float64_t>(w1, num_weights)) ;
for(int32_t i=0;i<num;i++)
{
if(a[i] != a_old[i])
{
for(int32_t j=0;j<num;j++)
W[j*num_kernels+n]+=(a[i]-a_old[i])*compute_kernel(i,j)*(float64_t)label[i];
}
}
w1[n]=0.0 ;
}
// restore old weights
kernel->set_subkernel_weights(SGVector<float64_t>(w_backup,num_weights));
SG_FREE(w_backup);
SG_FREE(w1);
}
call_mkl_callback(a, label, lin, c, totdoc);
}