Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doubt in Viterbi implementation #3

Open
tarunrkk opened this issue Apr 24, 2017 · 1 comment
Open

Doubt in Viterbi implementation #3

tarunrkk opened this issue Apr 24, 2017 · 1 comment

Comments

@tarunrkk
Copy link

Hi,

I am confused wrt lines 26 and 27 of the viterbi implementation:
trellis[:, t] = (trellis[:, t-1, None].dot(self.Obs(obs[t]).T) * self.transProb).max(0) backpt[:, t] = (np.tile(trellis[:, t-1, None], [1, self.N]) * self.transProb).argmax(0)

I am not able to understand why there is no dot product happening in the second line. Why multiply only with transProb without taking obs into account?

Please help.

@phvu
Copy link
Owner

phvu commented Apr 25, 2017

@tarunrkk: backpt is the backtrace to keep track the maximum decoding path. At timestep t, the backpt array keeps track of the best path so far up to timestep t-1. The observation probabilities obs at time t is taken into account in trellis at timestep t, which is taken into account in backpt at timestep t+1.
If it is still confusing, here is the algorithm for your reference: https://phvuresearch.files.wordpress.com/2013/12/viterbi_algo.png?w=1024&h=704

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants