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)
| 995 | |
| 996 | |
| 997 | def _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 | |
| 1024 | def _forward_backward_log(state_trans_log_probs, initial_state_log_probs, |
no test coverage detected