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


C++ DataPoint::adjoint方法代码示例

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


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

示例1: learn


//.........这里部分代码省略.........
        int bestRightMass = N;
        DataPoint bestProjection(D);

        // Optimize over all features
        for (int f = 0; f < numFeatures; f++)
        {
            // Sample a projection dimension
            DataPoint projection = DataPoint::Zero(D);
#if 0
            float length = 0;
            for (int d = 0; d < D; d++)
            {
                projection(d) = normal(g);
                length += projection(d)*projection(d);
            }
            // Normalize the projection
            projection /= std::sqrt(length);
#else
            for (int s = 0; s < sparsity; s++)
            {
                projection(dimensionDist(g)) = 2*rademacher(g) - 1;
            }
            projection /= std::sqrt(static_cast<float>(sparsity));
#endif
            
            // Initialize the histograms
            leftHistogram.reset();
            rightHistogram = hist;
            
            // Set up the array of projection values
            for (int m = 0; m < N; m++)
            {
                const int n = trainingExampleList[m];
                const float inner = projection.adjoint()*storage->getDataPoint(n);
                
                if (inner < 0)
                {
                    // Move the last point to the left histogram
                    leftHistogram.addOne(storage->getClassLabel(n));
                    rightHistogram.subOne(storage->getClassLabel(n));
                }
            }
            
            // Get the objective function
            const float localObjective = leftHistogram.getEntropy()
                    + rightHistogram.getEntropy();
                
            if (localObjective < bestObjective)
            {
                // Get the threshold value
                bestProjection = projection;
                bestObjective = localObjective;
                bestLeftMass = leftHistogram.getMass();
                bestRightMass = rightHistogram.getMass();
            }
        }
        
        // Did we find good split values?
        if (bestObjective > 1e20 || bestLeftMass < minChildSplitExamples || bestRightMass < minChildSplitExamples)
        {
            // We didn't
            // Don't split
            updateLeafNodeHistogram(tree->getNodeData(node).histogram, hist, smoothingParameter, useBootstrap);
            BOOST_ASSERT(tree->getNodeData(node).histogram.size() > 0);
            delete[] trainingExampleList;
            state.processed += N;
开发者ID:TobyPDE,项目名称:libforest,代码行数:67,代码来源:classifier_learning.cpp


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