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


C++ network::push方法代码示例

本文整理汇总了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;
}
开发者ID:mkknts35,项目名称:ANN,代码行数:35,代码来源:ann.cpp

示例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
}
开发者ID:mkknts35,项目名称:ANN,代码行数:41,代码来源:ann.cpp


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