本文整理汇总了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);
}
示例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;
}