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

Function _sum_states

tensorflow/python/ops/ctc_ops.py:997–1021  ·  view source on GitHub ↗

Take logsumexp for each unique state out of all label states. Args: idx: tensor of shape [batch, label_length] For each sequence, indices into a set of unique labels as computed by calling unique. states: tensor of shape [frames, batch, label_length] Log probabilities for each

(idx, states)

Source from the content-addressed store, hash-verified

995
996
997def _sum_states(idx, states):
998 """Take logsumexp for each unique state out of all label states.
999
1000 Args:
1001 idx: tensor of shape [batch, label_length] For each sequence, indices into a
1002 set of unique labels as computed by calling unique.
1003 states: tensor of shape [frames, batch, label_length] Log probabilities for
1004 each label state.
1005
1006 Returns:
1007 tensor of shape [frames, batch_size, label_length], log probabilites summed
1008 for each unique label of the sequence.
1009 """
1010
1011 with ops.name_scope("sum_states"):
1012 idx = ops.convert_to_tensor(idx, name="idx")
1013 num_states = _get_dim(states, 2)
1014 states = array_ops.expand_dims(states, axis=2)
1015 one_hot = array_ops.one_hot(
1016 idx,
1017 depth=num_states,
1018 on_value=0.0,
1019 off_value=math_ops.log(0.0),
1020 axis=1)
1021 return math_ops.reduce_logsumexp(states + one_hot, axis=-1)
1022
1023
1024def _forward_backward_log(state_trans_log_probs, initial_state_log_probs,

Callers 1

_state_to_olabel_uniqueFunction · 0.85

Calls 4

_get_dimFunction · 0.70
name_scopeMethod · 0.45
expand_dimsMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected