Viterbi algorithm

The Viterbi algorithm is one of most common decoding algorithms for HMM. Its goal is to find the most likely hidden state sequence corresponding to a series of observations. The structure is very similar to the forward algorithm, but instead of computing the probability of a sequence of observations joined with the state at the last time instant, this algorithm looks for:

The variable vti represents that maximum probability of the given observation sequence joint with xt = i, considering all possible hidden state paths (from time instant 1 to t-1). We can compute vti recursively by evaluating all the vt-1j multiplied by the corresponding transition probabilities pji and emission probability P(ot|xi), and always picking the maximum overall possible values of j:

The algorithm is based on a backtracking approach, using a backpointer bpti whose recursive expression is the same as vti, but with the argmax function instead of max:

Therefore, bpti represents the partial sequence of hidden states x1, x2, ..., xt-1 that maximizes vti. During the recursion, we add the timesteps one by one, so the previous path could be invalidated by the last observation. That's why we need to backtrack the partial result and replace the sequence built at time t that doesn't maximize vt+1i anymore.

The algorithm is based on the following steps (like in the other cases, the initial and ending states are not emitting):

  1. Initialization of a vector V with shape (N + 2, Sequence Length).
  2. Initialization of a vector BP with shape (N + 2, Sequence Length).
  3. Initialization of A (transition probability matrix) with shape (N, N). Each element is P(xi|xj).
  4. Initialization of B with shape (Sequence Length, N). Each element is P(oi|xj).
  5. For i=1 to N:
    1. Set V[i, 1]A[i, 0· B[1, i]
    2. BP[i, 1] = Null (or any other value that cannot be interpreted as a state)
  6. For t=1 to Sequence Length:
    1. For i=1 to N:
      1. Set V[i, t] = maxj V[j, t-1] · A[j, i] · B[t, i]
      2. Set BP[i, t] = argmaxj V[j, t-1] · A[j, i] · B[t, i]
  7. Set V[xEndind, Sequence Length] = maxj V[j, Sequence Length] · A[j, xEndind].
  1. Set BP[xEndind, Sequence Length] = argmaxj V[j, Sequence Length] · A[j, xEndind].
  2. Reverse BP.

The output of the Viterbi algorithm is a tuple with the most likely sequence BP, and the corresponding probabilities V.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.73.175