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


C++ Model::getOutputLabel方法代码示例

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


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

示例1: convertActivationsToLabels

static util::StringVector getReferenceLabels(network::Bundle& bundle,
    const model::Model& model)
{
    if(bundle.contains("referenceLabels"))
    {
        util::StringVector labels;

        auto& referenceLabels = bundle["referenceLabels"].get<matrix::LabelVector>();

        for(auto& referenceLabel : referenceLabels)
        {
            labels.push_back(std::string());

            for(auto& grapheme : referenceLabel)
            {
                labels.back() += model.getOutputLabel(grapheme);
            }
        }

        return labels;
    }

    auto& referenceActivations =
        bundle["referenceActivations"].get<matrix::MatrixVector>().front();

    return convertActivationsToLabels(std::move(referenceActivations), model);
}
开发者ID:sudnya,项目名称:video-classifier,代码行数:27,代码来源:ClassifierEngine.cpp

示例2: convertActivationsToGraphemeLabels

static util::StringVector convertActivationsToGraphemeLabels(matrix::Matrix&& activations,
    const model::Model& model)
{
    assert(activations.size().size() >= 3);

    if(activations.size().size() > 3)
    {
        activations = reshape(activations,
            {activations.size().front(),
             activations.size()[1],
             activations.size().product() / (activations.size().front() * activations.size()[1])});
    }

    size_t timesteps     = activations.size()[2];
    size_t miniBatchSize = activations.size()[1];
    size_t graphemes     = activations.size()[0];

    util::StringVector labels;

    for(size_t miniBatch = 0; miniBatch < miniBatchSize; ++miniBatch)
    {
        std::string currentLabel;

        size_t currentGrapheme = graphemes;

        for(size_t timestep = 0; timestep < timesteps; ++timestep)
        {
            size_t maxGrapheme = 0;
            double maxValue    = std::numeric_limits<double>::min();

            for(size_t grapheme = 0; grapheme < graphemes; ++grapheme)
            {
                if(activations(grapheme, miniBatch, timestep) >= maxValue)
                {
                    maxValue    = activations(grapheme, miniBatch, timestep);
                    maxGrapheme = grapheme;
                }
            }

            if(maxGrapheme != currentGrapheme)
            {
                currentGrapheme = maxGrapheme;
                auto newGrapheme = model.getOutputLabel(maxGrapheme);

                currentLabel.insert(currentLabel.end(), newGrapheme.begin(), newGrapheme.end());
            }

        }

        labels.push_back(currentLabel);
    }

    return labels;
}
开发者ID:sudnya,项目名称:video-classifier,代码行数:54,代码来源:ClassifierEngine.cpp


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