View source on GitHub
|
Performs greedy decoding on the logits given in input (best path).
tf.nn.ctc_greedy_decoder(
inputs, sequence_length, merge_repeated=True, blank_index=None
)
Given a tensor as inputs, the blank_index parameter defines the class
index of the blank symbol.
For example:
If blank_index is equal to 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)
Notes:
- Regardless of the value of
merge_repeated, if an index of a given time and batch corresponds to theblank_index, no new element is emitted. - Default
blank_indexis(num_classes - 1), unless overriden.
If merge_repeated is True, merge repeated classes in output.
This means that if consecutive logits' maximum indices are the same,
only the first of these is emitted. The sequence A B B * B * B (where '*'
is the blank label) becomes
A B B Bifmerge_repeated=True.A B B B Bifmerge_repeated=False.
View source on GitHub