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


C++ CKernel::get_kernel_matrix方法代码示例

本文整理汇总了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);
	}
}
开发者ID:AlexBinder,项目名称:shogun,代码行数:43,代码来源:GaussianProcessRegression.cpp

示例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);
	}
}
开发者ID:,项目名称:,代码行数:39,代码来源:

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


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