对输入中给出的 logits 执行贪心解码(最佳路径)。
用法
tf.nn.ctc_greedy_decoder(
inputs, sequence_length, merge_repeated=True, blank_index=None
)参数
-
inputs3-DfloatTensor大小为[max_time, batch_size, num_classes]。日志。 -
sequence_length包含序列长度的一维int32向量,大小为[batch_size]。 -
merge_repeated布尔值。默认值:真。 -
blank_index(可选的)。默认值:num_classes - 1。定义用于空白标签的类索引。负值将从 num_classes 开始,即 -1 将重现 ctc_greedy_decoder 使用 num_classes 的行为 - 1 对应于默认值。
返回
-
一个元组
(decoded, neg_sum_logits)其中 -
decodedsingle-element 列表。decoded[0]是一个SparseTensor包含解码的输出 s.t.:decoded.indices:索引矩阵(total_decoded_outputs, 2)。行存储:[batch, time]。decoded.values:值向量,大小(total_decoded_outputs)。向量存储解码的类。decoded.dense_shape:形状矢量,大小(2)。形状值为:[batch_size, max_decoded_length] -
neg_sum_logits一个float矩阵(batch_size x 1)包含,对于找到的序列,每个时间帧的最大 logit 总和的负数。
给定一个张量为 inputs ,blank_index 参数定义空白符号的类索引。
例如:
如果 blank_index 等于 1:
inf = float("inf")
logits = tf.constant([[[ 0., -inf, -inf],
[ -2.3, -inf, -0.1]],
[[ -inf, -0.5, -inf],
[ -inf, -inf, -0.1]],
[[ -inf, -inf, -inf],
[ -0.1, -inf, -2.3]]])
seq_lens = tf.constant([2, 3])
outputs = tf.nn.ctc_greedy_decoder(
logits,
seq_lens,
blank_index=1)
注意:
- 无论
merge_repeated的值如何,如果给定时间和批次的索引对应于blank_index,则不会发出新元素。 - 默认
blank_index是(num_classes - 1),除非被覆盖。
如果 merge_repeated 是 True ,则合并输出中的重复类。这意味着如果连续 logits 的最大索引相同,则仅发出其中的第一个。序列 A B B * B * B(其中 '*' 是空白标签)变为
A B B B如果merge_repeated=True。A B B B B如果merge_repeated=False。
相关用法
- Python tf.nn.compute_average_loss用法及代码示例
- Python tf.nn.conv2d用法及代码示例
- Python tf.nn.convolution用法及代码示例
- Python tf.nn.embedding_lookup_sparse用法及代码示例
- Python tf.nn.RNNCellResidualWrapper.set_weights用法及代码示例
- Python tf.nn.dropout用法及代码示例
- Python tf.nn.gelu用法及代码示例
- Python tf.nn.RNNCellDeviceWrapper.set_weights用法及代码示例
- Python tf.nn.embedding_lookup用法及代码示例
- Python tf.nn.RNNCellDeviceWrapper.get_weights用法及代码示例
- Python tf.nn.local_response_normalization用法及代码示例
- Python tf.nn.scale_regularization_loss用法及代码示例
- Python tf.nn.RNNCellResidualWrapper.add_loss用法及代码示例
- Python tf.nn.max_pool用法及代码示例
- Python tf.nn.RNNCellDropoutWrapper.set_weights用法及代码示例
- Python tf.nn.l2_loss用法及代码示例
- Python tf.nn.log_softmax用法及代码示例
- Python tf.nn.weighted_cross_entropy_with_logits用法及代码示例
- Python tf.nn.dilation2d用法及代码示例
- Python tf.nn.RNNCellResidualWrapper.get_weights用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.nn.ctc_greedy_decoder。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
