githubharald / CTCDecoder

Connectionist Temporal Classification (CTC) decoding algorithms: best path, beam search, lexicon search, prefix search, and token passing. Implemented in Python.
https://towardsdatascience.com/3797e43a86c
MIT License
817 stars 182 forks source link

Character level probability #13

Closed meet-minimalist closed 5 years ago

meet-minimalist commented 5 years ago

How to get the character level probability along with the string output?

githubharald commented 5 years ago

For the complete sequence the probability is BeamEntry.prTotal . For individual chars the easiest way would be to use best path decoding and then analyze the best path (e.g. take maximum or average of prob if a char is distributed across multiple time-steps).

meet-minimalist commented 4 years ago

@githubharald so it is not possible to find individual character probabalities in case of beam search. Right?

githubharald commented 4 years ago

it should be possible, as the probabilities for the last character of a beam are taken into account (see variable prNonBlank ) in each iteration. So, each time a character is added to the beam, the probability of this character is known, and also if a character spreads multiple time-steps, this is taken into account, so all the information needed is accessible. It's just about extracting this information while the algorithm iterates through the sequence.

But just to be clear - I would also have to think about how to do it, so please don't expect me to give you instruction on how to implement this or even expect an implementation, you would really have to do it yourself.

meet-minimalist commented 4 years ago

I have done exactly the same but I somehow was not able to get the results. May be due to coding error.

But thanks for the idea. 😊