本文整理汇总了C++中network::push方法的典型用法代码示例。如果您正苦于以下问题:C++ network::push方法的具体用法?C++ network::push怎么用?C++ network::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network
的用法示例。
在下文中一共展示了network::push方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: push
//============================================================================
double push(network net, shared_ptr<vector<sample>> dataSet)
{
vector<double> input;
vector<double> expected;
vector<double> actual;
double correct = 0;
int i = 0;
vector<sample>::iterator currentSample = dataSet->begin();
//network dnet(data.getTableName(), data.getAttributeCount(), data.getCatagoryCount(), HIDDEN_LAYERS, LAYER_SIZE);
while(currentSample != dataSet->end()){
//currentSample->printSample();
input = currentSample->getValues();
expected = m_typeToVector[currentSample->getClassification()];
actual = net.push(input);
if (m_data.classVector(m_data.getCatagoryCount(), catagorize(actual)) == expected) correct++;
if (i % 10 == 0 && !m_quiet) {
cout << "Actual = ";
printVector(actual);
cout << " ";
cout << "Expected = ";
printVector(expected);
if (m_data.classVector(m_data.getCatagoryCount(), catagorize(actual)) != expected){
cout << " x";
}
cout << endl;
}
i++;
currentSample++;
}
double total = m_data.getSampleCount();
double percent = (correct / total) * 100;
cout << correct << "/" << total << " = " << percent << "% correct." << endl;
return percent;
}
示例2: 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
}