1 C++ 在CTC解码算法后移除相邻重复和blank索引
在CTC Decode解码算法之后,比如说使用Greedy CTC Decode、Beam CTC decode、Prefix Beam CTC Decode算法之后,通常会得到包含blank索引的一个长序列,比如说
1,5,8,8,8,0,9,10,10,3,4
其中0表示blank,我们如果需要得到正确的结果,就需要将上述长序列中的blank和相邻的重复索引进行去除,比如说上述索引最终的正确结果如下
1,5,8,9,10,3,4
可以使用C++对上述功能进行实现,示例代码如下
#include <iostream>
#include <vector>
static std::vector<int> RemoveDuplicatesAndBlank(const std::vector<int>& hyp)
{
std::vector<int> result;
int current_index = 0;
while (current_index < hyp.size())
{
if (hyp[current_index] != 0)
result.emplace_back(hyp[current_index]);
int prev_index = current_index;
while (current_index < hyp.size() && hyp[current_index] == hyp[prev_index])
{
current_index += 1;
}
}
return result;
}
int main()
{
std::vector<int> a = {1,5,8,8,8,0,9,10,10,3,4 };
std::vector<int> b = RemoveDuplicatesAndBlank(a);
}
本文作者:StubbornHuang
版权声明:本文为站长原创文章,如果转载请注明原文链接!
原文标题:C++ – 在CTC解码算法后移除相邻重复和blank索引
原文链接:https://www.stubbornhuang.com/2463/
发布于:2022年12月22日 10:34:38
修改于:2023年06月21日 17:19:55
当前分类随机文章推荐
- C++ - Windows系统获取桌面路径 阅读474次,点赞0次
- OpenCV - OpenCV打开摄像头显示摄像头帧率 阅读349次,点赞0次
- C++ - Windows下字符串UTF8编码转ANSI,ANSI转UTF8编码 阅读803次,点赞0次
- C++ - 使用标准库实现事件和委托,信号和槽机制 阅读612次,点赞0次
- C++ - 对字符串和图片进行base64编解码 阅读1124次,点赞0次
- C++ - String literal,字符串关键字R,L,u8,u,U的作用 阅读218次,点赞0次
- C++11 - std::chrono - 使用std::chrono::duration_cast进行时间转换,hours/minutes/seconds/milliseconds/microseconds相互转换,以及自定义duration进行转换 阅读2546次,点赞0次
- GCC/G++中编译优化选项-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz各自的区别和作用 阅读5804次,点赞4次
- C++ - 获取std::vector中的最小值、最大值以及对应的索引 阅读496次,点赞0次
- C++11 - 委托机制的实现TinyDelegate 阅读1727次,点赞0次
全站随机文章推荐
- 如何选择一块合适的用于深度学习的GPU/显卡 阅读1675次,点赞0次
- 资源分享 - Unity Shader入门精要 PDF下载 阅读3247次,点赞0次
- 资源分享 - GPU Pro 6 - Advanced Rendering Techniques 英文高清PDF下载 阅读3048次,点赞0次
- 资源分享 - Texturing and Modeling - A Procedural Approach, Third Edition 英文高清PDF下载 阅读2465次,点赞0次
- C++ – 字节数组byte[]或者unsigned char[]与long double的相互转换 阅读1300次,点赞0次
- VTK能干什么?VTK大部分功能的细节简介,VTK能打开的文件格式 阅读6424次,点赞3次
- 资源分享 - GPGPU Programming for Games and Science 英文高清PDF下载 阅读1833次,点赞0次
- 资源分享 - Vulkan应用开发指南 , Vulkan Programming Guide - The Official Guide to Learning Vulkan中文版PDF下载 阅读1828次,点赞0次
- Python - list与字符串str相互转换方法总结 阅读931次,点赞0次
- CSS - 使用Katex渲染数学公式,数学公式过长超出页面范围的问题修正 阅读70次,点赞0次
评论
169