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


C++ MATRIX::begin方法代码示例

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


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

示例1: trainOnlineCV

void Backpropagation::trainOnlineCV(Mlp& network, 
	MATRIX& trainingInputs, 
	VECTOR& trainingTargets,
	MATRIX& testInputs,
	VECTOR& testTargets)
{
	VECTOR trainingOutputs(trainingTargets.size(), 0.0);
	VECTOR testOutputs(testTargets.size(), 0.0);
	
	while(error > tolerance && testCount < maxTestCount)
	{
		VECTOR::iterator output = trainingOutputs.begin();
		VECTOR::iterator target = trainingTargets.begin();
		for(MATRIX::iterator input = trainingInputs.begin(); 
			input != trainingInputs.end(); 
			++input, ++target, ++output)
		{
			*output = network(*input);
			double err = *output - *target;
			
			getWeightUpdates(network, *input, err);
			
			applyWeightUpdates(network);
			
			++iteration;
			
			if(iteration >= maxIterations)
				break;
		}
		
		++epoch;
		
		error = mse(trainingTargets, trainingOutputs);
		
		// Early-stopping using test (cross-validation) error
		testOutputs = network(testInputs);
		testError = mse(testTargets, testOutputs);
		if(testError < minTestError)
		{
			// Preserve test error and network weights
			minTestError = testError;
			W = network.W;			
			V = network.V;
			biasW = network.biasW;
			biasV = network.biasV;
			testCount = 0;
		}
		else
		{
			++testCount;
		}
	}
	
	network.W = W;
	network.V = V;
	network.biasW = biasW;
	network.biasV = biasV;
	testError = minTestError;
}
开发者ID:Re-bort,项目名称:NNDK,代码行数:59,代码来源:Backpropagation.cpp

示例2: trainOnline

void Backpropagation::trainOnline(Mlp& network, MATRIX& inputs, VECTOR& targets)
{
	VECTOR outputs(targets.size(), 0.0);
	while(iteration < maxIterations)
	{
		VECTOR::iterator output = outputs.begin();
		VECTOR::iterator target = targets.begin();
		for(MATRIX::iterator input = inputs.begin(); 
			input != inputs.end(); 
			++input, ++target, ++output)
		{
			*output = network(*input);
			double err = *output - *target;
			
			getWeightUpdates(network, *input, err);
			
			applyWeightUpdates(network);
			
			++iteration;
		}
		++epoch;
	}
}
开发者ID:Re-bort,项目名称:NNDK,代码行数:23,代码来源:Backpropagation.cpp


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