本文整理汇总了C++中network::train方法的典型用法代码示例。如果您正苦于以下问题:C++ network::train方法的具体用法?C++ network::train怎么用?C++ network::train使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network
的用法示例。
在下文中一共展示了network::train方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: train
//============================================================================
void train(network net, shared_ptr<vector<sample>> dataSet)
{
vector<double> input;
vector<double> expected;
vector<double> actual;
vector<sample>::iterator currentSample = dataSet->begin();
#if WINDOWSSYSTEM
FILETIME tStart, tEnd;
GetSystemTimeAsFileTime(&tStart);
#else
struct timeval profileStart, profileEnd;
gettimeofday(&profileStart, NULL);
#endif
int p = 0, oldp = -1;
int iterations = m_data.getSampleCount() * ITERATIONS;
outputStatusMessage("Training the network");
for (unsigned int g = 0; g < ITERATIONS; g++) {
p = calcPercentageComplete(g, ITERATIONS);
if (oldp < p) {
oldp = updateOutputPercentage(p, false);
}
currentSample = dataSet->begin();
while(currentSample != dataSet->end()){
input = currentSample->getValues();
expected = m_typeToVector[currentSample->getClassification()];
actual = net.push(input);
net.train(input, expected);
currentSample++;
}
}
updateOutputPercentage(p, true);
#if WINDOWSSYSTEM
GetSystemTimeAsFileTime(&tEnd);
PrintTimeDifference(tStart, tEnd);
#else
gettimeofday(&profileEnd, NULL);
PrintTimeDifference(profileStart, profileEnd);
#endif
}