Skip to content

Instantly share code, notes, and snippets.

View githubharald's full-sized avatar

Harald Scheidl githubharald

View GitHub Profile
@githubharald
githubharald / ctc_score.py
Created August 2, 2018 10:08
Compute confidence score for CTC-decoded text using TensorFlow
"""
Compute score for decoded text in a CTC-trained neural network using TensorFlow:
1. decode text with best path decoding (or some other decoder)
2. feed decoded text into loss function
3. loss is negative logarithm of probability
Example data: two time-steps, 2 labels (0, 1) and the blank label (2).
Decoding results in [0] (i.e. string containing one entry for label 0).
The probability is the sum over all paths yielding [0], these are: [0, 0], [0, 2], [2, 0]
with probability