本文整理汇总了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;
}
示例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;
}
}