MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _state_to_olabel

Function _state_to_olabel

tensorflow/python/ops/ctc_ops.py:526–541  ·  view source on GitHub ↗

Sum state log probs to ilabel log probs.

(labels, num_labels, states)

Source from the content-addressed store, hash-verified

524
525
526def _state_to_olabel(labels, num_labels, states):
527 """Sum state log probs to ilabel log probs."""
528
529 num_label_states = _get_dim(labels, 1) + 1
530 label_states = states[:, :, 1:num_label_states]
531 blank_states = states[:, :, num_label_states:]
532 one_hot = array_ops.one_hot(
533 labels - 1,
534 depth=(num_labels - 1),
535 on_value=0.0,
536 off_value=math_ops.log(0.0))
537 one_hot = array_ops.expand_dims(one_hot, axis=0)
538 label_states = array_ops.expand_dims(label_states, axis=3)
539 label_olabels = math_ops.reduce_logsumexp(label_states + one_hot, axis=2)
540 blank_olabels = math_ops.reduce_logsumexp(blank_states, axis=2, keepdims=True)
541 return array_ops.concat([blank_olabels, label_olabels], axis=-1)
542
543
544# pylint: disable=redefined-outer-name

Callers 1

ctc_loss_and_gradFunction · 0.85

Calls 4

_get_dimFunction · 0.70
logMethod · 0.45
expand_dimsMethod · 0.45
concatMethod · 0.45

Tested by

no test coverage detected