当前位置: 首页>>代码示例>>C++>>正文


C++ CKernel类代码示例

本文整理汇总了C++中CKernel的典型用法代码示例。如果您正苦于以下问题:C++ CKernel类的具体用法?C++ CKernel怎么用?C++ CKernel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CKernel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: REQUIRE

CMulticlassLabels* CRelaxedTree::apply_multiclass(CFeatures* data)
{
    if (data != NULL)
    {
        CDenseFeatures<float64_t> *feats = dynamic_cast<CDenseFeatures<float64_t>*>(data);
        REQUIRE(feats != NULL, ("Require non-NULL dense features of float64_t\n"))
        set_features(feats);
    }

    // init kernels for all sub-machines
    for (int32_t i=0; i<m_machines->get_num_elements(); i++)
    {
        CSVM *machine = (CSVM*)m_machines->get_element(i);
        CKernel *kernel = machine->get_kernel();
        CFeatures* lhs = kernel->get_lhs();
        kernel->init(lhs, m_feats);
        SG_UNREF(machine);
        SG_UNREF(kernel);
        SG_UNREF(lhs);
    }

    CMulticlassLabels *lab = new CMulticlassLabels(m_feats->get_num_vectors());
    SG_REF(lab);
    for (int32_t i=0; i < lab->get_num_labels(); ++i)
    {
        lab->set_int_label(i, int32_t(apply_one(i)));
    }

    return lab;
}
开发者ID:behollis,项目名称:muViewBranch,代码行数:30,代码来源:RelaxedTree.cpp

示例2: get_first_kernel

bool CCombinedKernel::delete_optimization()
{
	CListElement* current = NULL ;
	CKernel* k = get_first_kernel(current);

	while(k)
	{
		if (k->has_property(KP_LINADD))
			k->delete_optimization();

		SG_UNREF(k);
		k = get_next_kernel(current);
	}

	SG_FREE(sv_idx);
	sv_idx = NULL;

	SG_FREE(sv_weight);
	sv_weight = NULL;

	sv_count = 0;
	set_is_initialized(false);

	return true;
}
开发者ID:TharinduRusira,项目名称:shogun,代码行数:25,代码来源:CombinedKernel.cpp

示例3: ASSERT

void CCombinedKernel::compute_batch(
	int32_t num_vec, int32_t* vec_idx, float64_t* result, int32_t num_suppvec,
	int32_t* IDX, float64_t* weights, float64_t factor)
{
	ASSERT(num_vec<=get_num_vec_rhs())
	ASSERT(num_vec>0);
	ASSERT(vec_idx);
	ASSERT(result);

	//we have to do the optimization business ourselves but lets
	//make sure we start cleanly
	delete_optimization();

	CListElement* current = NULL ;
	CKernel * k = get_first_kernel(current) ;

	while(k)
	{
		if (k && k->has_property(KP_BATCHEVALUATION))
		{
			if (k->get_combined_kernel_weight()!=0)
				k->compute_batch(num_vec, vec_idx, result, num_suppvec, IDX, weights, k->get_combined_kernel_weight());
		}
		else
			emulate_compute_batch(k, num_vec, vec_idx, result, num_suppvec, IDX, weights);

		SG_UNREF(k);
		k = get_next_kernel(current);
	}

	//clean up
	delete_optimization();
}
开发者ID:TharinduRusira,项目名称:shogun,代码行数:33,代码来源:CombinedKernel.cpp

示例4: main

int main (void)
{
	// TODO: implement all destructors used in CKernel, otherwise cannot return from main()

	CKernel Kernel;
	if (!Kernel.Initialize ())
	{
		DisableInterrupts ();
		for (;;);
		return EXIT_HALT;
	}
	
	TShutdownMode ShutdownMode = Kernel.Run ();

	switch (ShutdownMode)
	{
	case ShutdownReboot:
		reboot ();
		return EXIT_REBOOT;

	case ShutdownHalt:
	default:
		DisableInterrupts ();
		for (;;);
		return EXIT_HALT;
	}
}
开发者ID:tufty,项目名称:circle,代码行数:27,代码来源:main.cpp

示例5: kprintf

void CKernel::Start(void)
{
    if (m_dwMagic != CKERNEL_MAGIC)
    {
        kprintf("[e] Error! My constructor wasn't called properly.\n");
        return;
    }
    kprintf("wat\n");
    
    m_Logger = new CLogger();
    Alentours::CPCIManager::Initialize();

    CKernelML4 *ML4 = new CKernelML4();
    CTask *KernelTask = new CTask(*ML4);
    CScheduler::AddTask(KernelTask);
    kprintf("[i] Kernel task has PID %i.\n", KernelTask->GetPID());
        
    ML4->Apply();
    KernelTask->UseStack([](CTask *Task) {
        kprintf("[i] Switched to Tier1 stack\n");

        // After enabling, only CScheduler::* calls are allowed for API
        CScheduler::Enable();
        kprintf("[i] Enabled scheduler.\n");

        g_Kernel.SpawnThreads();
        CScheduler::Exit();
    });
}
开发者ID:q3k,项目名称:Cucumber,代码行数:29,代码来源:CKernel.cpp

示例6: SG_DEBUG

const float64_t* CCombinedKernel::get_subkernel_weights(int32_t& num_weights)
{
	SG_DEBUG("entering CCombinedKernel::get_subkernel_weights()\n");

	num_weights = get_num_subkernels() ;
	SG_FREE(subkernel_weights_buffer);
	subkernel_weights_buffer = SG_MALLOC(float64_t, num_weights);

	if (append_subkernel_weights)
	{
		SG_DEBUG("appending kernel weights\n");

		int32_t i=0 ;
		CListElement* current = NULL ;
		CKernel* k = get_first_kernel(current);
		while(k)
		{
			int32_t num = -1 ;
			const float64_t *w = k->get_subkernel_weights(num);
			ASSERT(num==k->get_num_subkernels());
			for (int32_t j=0; j<num; j++)
				subkernel_weights_buffer[i+j]=w[j] ;

			SG_UNREF(k);
			k = get_next_kernel(current);
			i += num ;
		}
	}
	else
	{
		SG_DEBUG("not appending kernel weights\n");
		int32_t i=0 ;
		CListElement* current = NULL ;
		CKernel* k = get_first_kernel(current);
		while(k)
		{
			subkernel_weights_buffer[i] = k->get_combined_kernel_weight();

			SG_UNREF(k);
			k = get_next_kernel(current);
			i++ ;
		}
	}

	SG_DEBUG("leaving CCombinedKernel::get_subkernel_weights()\n");
	return subkernel_weights_buffer ;
}
开发者ID:TharinduRusira,项目名称:shogun,代码行数:47,代码来源:CombinedKernel.cpp

示例7: list_kernels

void CCombinedKernel::list_kernels()
{
	CKernel* k;

	SG_INFO( "BEGIN COMBINED KERNEL LIST - ");
	this->list_kernel();

	CListElement* current = NULL ;
	k=get_first_kernel(current);
	while (k)
	{
		k->list_kernel();
		SG_UNREF(k);
		k=get_next_kernel(current);
	}
	SG_INFO( "END COMBINED KERNEL LIST - ");
}
开发者ID:TharinduRusira,项目名称:shogun,代码行数:17,代码来源:CombinedKernel.cpp

示例8: compute_mkl_dual_objective

// assumes that all constraints are satisfied
float64_t CMKL::compute_mkl_dual_objective()
{
	int32_t n=get_num_support_vectors();
	float64_t mkl_obj=0;

	if (labels && kernel && kernel->get_kernel_type() == K_COMBINED)
	{
		CKernel* kn = ((CCombinedKernel*)kernel)->get_first_kernel();
		while (kn)
		{
			float64_t sum=0;
			for (int32_t i=0; i<n; i++)
			{
				int32_t ii=get_support_vector(i);

				for (int32_t j=0; j<n; j++)
				{
					int32_t jj=get_support_vector(j);
					sum+=get_alpha(i)*get_alpha(j)*kn->kernel(ii,jj);
				}
			}

			if (mkl_norm==1.0)
				mkl_obj = CMath::max(mkl_obj, sum);
			else
				mkl_obj += CMath::pow(sum, mkl_norm/(mkl_norm-1));

			SG_UNREF(kn);
			kn = ((CCombinedKernel*) kernel)->get_next_kernel();
		}

		if (mkl_norm==1.0)
			mkl_obj=-0.5*mkl_obj;
		else
			mkl_obj= -0.5*CMath::pow(mkl_obj, (mkl_norm-1)/mkl_norm);

		mkl_obj+=compute_sum_alpha();
	}
	else
		SG_ERROR( "cannot compute objective, labels or kernel not set\n");

	return -mkl_obj;
}
开发者ID:memimo,项目名称:shogun-liblinear,代码行数:44,代码来源:MKL.cpp

示例9: main

int main(int argc, char *argv[])
{
	CLog log;
	log.Init(Debug, "TestApp");
	LogInfo("Starting app (%s)", g_strBuildStamp.c_str());
	CProfiler profile("main", 3, Info);

	CKernel *pKernel = CKernel::Create();
	pKernel->AddTask(CTimerTask::Create(10));
	pKernel->AddTask(CInputTask::Create(20));
	pKernel->AddTask(CInterpolatorTask::Create(30));
	pKernel->AddTask(CTriggerTask::Create(40));
	pKernel->AddTask(CCameraTask::Create(50));
	pKernel->AddTask(CConsoleTask::Create(9000));
	pKernel->AddTask(CVideoTask::Create(10000));

	pKernel->AddTask(CAppTask::Create(100));
	pKernel->Execute();
	pKernel->Destroy();

	LogInfo("Closing app");
	return 0;
}
开发者ID:sukharev,项目名称:phd,代码行数:23,代码来源:TestApp.cpp

示例10: main

int main (void)
{
	// cannot return here because some destructors used in CKernel are not implemented

	if (!Kernel.Initialize ())
	{
		halt ();
		return EXIT_HALT;
	}
	
	TShutdownMode ShutdownMode = Kernel.Run ();

	switch (ShutdownMode)
	{
	case ShutdownReboot:
		reboot ();
		return EXIT_REBOOT;

	case ShutdownHalt:
	default:
		halt ();
		return EXIT_HALT;
	}
}
开发者ID:meesokim,项目名称:spc1000,代码行数:24,代码来源:main.cpp

示例11: 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();

		if (m_method->get_latent_features())
			kernel->init(m_method->get_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->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);
	}
}
开发者ID:,项目名称:,代码行数:43,代码来源:

示例12: 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;
}
开发者ID:TharinduRusira,项目名称:shogun,代码行数:87,代码来源:CombinedKernel.cpp

示例13: invalidate_test

void CGUIFeatures::invalidate_test()
{
	CKernel *k = ui->ui_kernel->get_kernel();
	if (k)
		k->remove_rhs();
}
开发者ID:42MachineLearning,项目名称:shogun,代码行数:6,代码来源:GUIFeatures.cpp

示例14: registerPlugin

extern "C" void registerPlugin(CKernel &kernel)
{
    kernel.getTestSuitePrioritizationPluginManager().addPlugin(new GeneralIgnorePrioritizationPlugin());
}
开发者ID:sed-szeged,项目名称:soda,代码行数:4,代码来源:GeneralIgnorePrioritizationPlugin.cpp

示例15: mu

SGVector<int32_t> CRelaxedTree::train_node_with_initialization(const CRelaxedTree::entry_t &mu_entry, SGVector<int32_t> classes, CSVM *svm)
{
    SGVector<int32_t> mu(classes.vlen), prev_mu(classes.vlen);
    mu.zero();
    mu[mu_entry.first.first] = 1;
    mu[mu_entry.first.second] = -1;

    SGVector<int32_t> long_mu(m_num_classes);
    svm->set_C(m_svm_C, m_svm_C);
    svm->set_epsilon(m_svm_epsilon);

    for (int32_t iiter=0; iiter < m_max_num_iter; ++iiter)
    {
        long_mu.zero();
        for (int32_t i=0; i < classes.vlen; ++i)
        {
            if (mu[i] == 1)
                long_mu[classes[i]] = 1;
            else if (mu[i] == -1)
                long_mu[classes[i]] = -1;
        }

        SGVector<int32_t> subset(m_feats->get_num_vectors());
        SGVector<float64_t> binlab(m_feats->get_num_vectors());
        int32_t k=0;

        CMulticlassLabels *labs = dynamic_cast<CMulticlassLabels *>(m_labels);
        for (int32_t i=0; i < binlab.vlen; ++i)
        {
            int32_t lab = labs->get_int_label(i);
            binlab[i] = long_mu[lab];
            if (long_mu[lab] != 0)
                subset[k++] = i;
        }

        subset.vlen = k;

        CBinaryLabels *binary_labels = new CBinaryLabels(binlab);
        SG_REF(binary_labels);
        binary_labels->add_subset(subset);
        m_feats->add_subset(subset);

        CKernel *kernel = (CKernel *)m_kernel->shallow_copy();
        kernel->init(m_feats, m_feats);
        svm->set_kernel(kernel);
        svm->set_labels(binary_labels);
        svm->train();

        binary_labels->remove_subset();
        m_feats->remove_subset();
        SG_UNREF(binary_labels);

        std::copy(&mu[0], &mu[mu.vlen], &prev_mu[0]);

        mu = color_label_space(svm, classes);

        bool bbreak = true;
        for (int32_t i=0; i < mu.vlen; ++i)
        {
            if (mu[i] != prev_mu[i])
            {
                bbreak = false;
                break;
            }
        }

        if (bbreak)
            break;
    }

    return mu;
}
开发者ID:behollis,项目名称:muViewBranch,代码行数:72,代码来源:RelaxedTree.cpp


注:本文中的CKernel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。