Tải bản đầy đủ (.ppt) (28 trang)

Hidden markov models

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (211.58 KB, 28 trang )

Hidden Markov Models
Ankur Jain
Y7073
What is Covered

Observable Markov Model

Hidden Markov Model

Evaluation problem

Decoding Problem

Set of states:

Process moves from one state to another generating a
sequence of states :

Markov chain property: probability of each subsequent state
depends only on what was the previous state:

To define Markov model, the following probabilities have to be
specified: transition probabilities and initial
probabilities

The output of the process is the set of states at each instant of
time
Markov Models
},,,{
21 N
sss 


 ,,,,
21 ikii
sss
)|(),,,|(
1121 −−
=
ikikikiiik
ssPssssP 
)|(
jiij
ssPa =
)(
ii
sP=
π

By Markov chain property, probability of state sequence can be
found by the formula:
Calculation of sequence probability
)()|()|()|(
),,,()|(
),,,(),,,|(),,,(
112211
1211
12112121
iiiikikikik
ikiiikik
ikiiikiiikikii
sPssPssPssP
sssPssP

sssPssssPsssP



−−−
−−
−−
=
==
=
Rain
Dry
0.70.3
0.2 0.8

Two states : ‘Rain’ and ‘Dry’.

Initial probabilities: say P(‘Rain’)=0.4 , P(‘Dry’)=0.6

Suppose we want to calculate a probability of a sequence of
states in our example, {‘Dry’,’Dry’,’Rain’,Rain’}.
P({‘Dry’,’Dry’,’Rain’,Rain’} ) = ??.
Example of Markov Model
Hidden Markov models.

The observation is turned to be a probabilistic function (discrete
or continuous) of a state instead of an one-to-one correspondence
of a state

Each state randomly generates one of M observations (or visible

states)

To define hidden Markov model, the following probabilities
have to be specified: matrix of transition probabilities A=(a
ij
),
a
ij
= P(s
i

| s
j
) , matrix of observation probabilities B=(b
i
(v
m
)),
b
i
(v
m
)

= P(v
m

| s
i
) and a vector of initial probabilities π=(π

i
),
π
i
= P(s
i
) . Model is represented by M=(A, B, π).
},,,{
21 M
vvv 
HMM Assumptions

Markov assumption: the state transition depends only on
the origin and destination

Output-independent assumption: all observation frames
are dependent on the state that generated them, not on
neighbouring observation frames
Low
High
0.70.3
0.2 0.8
Dry
Rain
0.6 0.6
0.4 0.4
Example of Hidden Markov Model

Two states : ‘Low’ and ‘High’ atmospheric pressure.


Two observations : ‘Rain’ and ‘Dry’.

Transition probabilities: P(‘Low’|‘Low’)=0.3 ,
P(‘High’|‘Low’)=0.7 , P(‘Low’|‘High’)=0.2,
P(‘High’|‘High’)=0.8

Observation probabilities : P(‘Rain’|‘Low’)=0.6 ,
P(‘Dry’|‘Low’)=0.4 , P(‘Rain’|‘High’)=0.4 ,
P(‘Dry’|‘High’)=0.3 .

Initial probabilities: say P(‘Low’)=0.4 , P(‘High’)=0.6 .
Example of Hidden Markov Model

Suppose we want to calculate a probability of a sequence of
observations in our example, {‘Dry’,’Rain’}.

Consider all possible hidden state sequences:
P({‘Dry’,’Rain’} ) = P({‘Dry’,’Rain’} , {‘Low’,’Low’}) +
P({‘Dry’,’Rain’} , {‘Low’,’High’}) + P({‘Dry’,’Rain’} ,
{‘High’,’Low’}) + P({‘Dry’,’Rain’} , {‘High’,’High’})
where first term is :
P({‘Dry’,’Rain’} , {‘Low’,’Low’})=
P({‘Dry’,’Rain’} | {‘Low’,’Low’}) P({‘Low’,’Low’}) = ??
Calculation of observation sequence probability
Evaluation problem. Given the HMM M=(A, B, π) and the
observation sequence O=o
1
o
2
o

K
, calculate the probability that
model M has generated sequence O .

Decoding problem. Given the HMM M=(A, B, π) and the
observation sequence O=o
1
o
2
o
K
, calculate the most likely
sequence of hidden states s
i
that produced this observation sequence
O.

Learning problem. Given some training observation sequences
O=o
1
o
2
o
K
and general structure of HMM (numbers of hidden
and visible states), adjust M=(A, B, π) to maximize the
probability.
O=o
1
o

K
denotes a sequence of observations o
k

{v
1
,…,v
M
}.
Main issues using HMMs :

Typed word recognition, assume all characters are separated.

Character recognizer outputs probability of the image being
particular character, P(image|character).
0.5
0.03
0.005
0.31
z
c
b
a
Word recognition example(1).
Hidden state Observation

Hidden states of HMM = characters.

Observations = typed images of characters segmented from the
image . Note that there is an infinite number of

observations

Observation probabilities = character recognizer scores.

Transition probabilities will be defined differently in two
subsequent models.
Word recognition example(2).
( ) ( )
)|()(
ii
svPvbB
αα
==
α
v

If lexicon is given, we can construct separate HMM models
for each lexicon word.
Amherst a m
h e
r
s
t
Buffalo b u
f f
a
l
o
0.5
0.03


Here recognition of word image is equivalent to the problem
of evaluating few HMM models.

This is an application of Evaluation problem.
Word recognition example(3).
0.4 0.6

We can construct a single HMM for all words.

Hidden states = all characters in the alphabet.

Transition probabilities and initial probabilities are calculated
from language model.

Observations and observation probabilities are as before.
a
m
h
e
r
s
t
b
v
f
o

Here we have to determine the best sequence of hidden states,
the one that most likely produced word image.


This is an application of Decoding problem.
Word recognition example(4).

Evaluation problem. Given the HMM M=(A, B, π) and the
observation sequence O=o
1
o
2
o
T
, calculate the probability that
model M has generated sequence O .

Direct Evaluation :Trying to find probability of observations
O=o
1
o
2
o
T
by means of considering all hidden state sequences

P(o
1
o
2
o
T
) = P(o

1
o
2
o
T

,
S ) {S is state sequence}

P(o
1
o
2
o
T
) = P(o
1
o
2
o
T
/S ) P(S)

P(S) = {Markov property}

P(o
1
o
2
o

T
/S ) = {Output independent assumption}
Evaluation Problem.

N
T
hidden state sequences - exponential complexity.

Use Forward-Backward HMM algorithms for efficient
calculations.

Define the forward variable α
k
(i) as the joint probability of
the partial observation sequence o
1
o
2
o
k
and that the
hidden state at time k is s
i
: α
k
(i)= P(o
1
o
2
o

k ,
q
k
=

s
i

)
s
1
s
2
s
i
s
N
s
1
s
2
s
i
s
N
s
1
s
2
s

j
s
N
s
1
s
2
s
i
s
N
a
1j
a
2j
a
ij
a
Nj
Time= 1 k k+1 K
o
1
o
k
o
k+1
o
K
= Observations
Trellis representation of an HMM


Initialization:
α
1
(i)= P(o
1 ,
q
1
=

s
i

) = π
i
b
i
(o
1
) , 1<=i<=N.

Forward recursion:
α
k+1
(j)= P(o
1
o
2
o
k+1 ,

q
k+1
=

s
j

) =
Σ
i
P(o
1
o
2
o
k+1 ,
q
k
=

s
i

,
q
k+1
=

s
j


) =
Σ
i
P(o
1
o
2
o
k ,
q
k
=

s
i
) a
ij
b
j
(o
k+1
) =

i
α
k
(i) a
ij
] b

j
(o
k+1
) , 1<=j<=N, 1<=k<=K-1.

Termination:
P(o
1
o
2
o
K
) = Σ
i
P(o
1
o
2
o
K ,
q
K
=

s
i
) = Σ
i
α
K

(i)

Complexity :
N
2
K operations.
Forward recursion for HMM

Define the backward variable β
k
(i) as the joint probability of the
partial observation sequence o
k+1
o
k+2
o
K
given that the hidden
state at time k is s
i
: β
k
(i)= P(o
k+1
o
k+2
o
K
|q
k

=

s
i

)

Initialization:
β
K
(i)= 1 , 1<=i<=N.

Backward recursion:
β
k
(j)= P(o
k+1
o
k+2
o
K
|

q
k
=

s
j


) =
Σ
i
P(o
k+1
o
k+2
o
K ,
q
k+1
=

s
i


|

q
k
=

s
j

) =
Σ
i
P(o

k+2
o
k+3
o
K
|

q
k+1
=

s
i
) a
ji
b
i
(o
k+1
) =
Σ
i
β
k+1
(i) a
ji
b
i
(o
k+1

) , 1<=j<=N, 1<=k<=K-1.

Termination:
P(o
1
o
2
o
K
) = Σ
i
P(o
1
o
2
o
K ,
q
1
=

s
i
) =
Σ
i
P(o
1
o
2

o
K
|q
1
=

s
i
) P(q
1
=

s
i
) = Σ
i
β
1
(i) b
i
(o
1
) π
i

Backward recursion for HMM

α
k
(i) β

k
(i) = P(o
1
o
2
o
K ,
q
k
=

s
i
)

P(o
1
o
2
o
K
) = Σ
i
α
k
(i) β
k
(i)

We want to find the state sequence Q= q

1
…q
K
which maximizes
P(Q | o
1
o
2
o
K
) , or equivalently P(Q , o
1
o
2
o
K
) .

Brute force consideration of all paths takes exponential time. Use
efficient Viterbi algorithm instead.

Define variable δ
k
(i) as the maximum probability of producing
observation sequence o
1
o
2
o
k

when moving along any hidden
state sequence q
1
… q
k-1
and getting into q
k
= s
i

.
δ
k
(i) = max P(q
1
… q
k-1
,

q
k
= s
i

,

o
1
o
2

o
k
)
where max is taken over all possible paths q
1
… q
k-1
.
Decoding problem

General idea:
if best path ending in q
k
= s
j

goes through q
k-1
= s
i

then it
should coincide with best path ending in q
k-1
= s
i

.
s
1

s
i
s
N
s
j
a
ij
a
Nj
a
1j
q
k-1
q
k


δ
k
(i) = max P(q
1
… q
k-1
,

q
k
= s
j


,

o
1
o
2
o
k
) =
max
i
[ a
ij
b
j
(o
k
) max P(q
1
… q
k-1
= s
i

,

o
1
o

2
o
k-1
) ]

To backtrack best path keep info that predecessor of s
j
was s
i
.
Viterbi algorithm (1)

Initialization:
δ
1
(i) = max P(q
1
= s
i

,

o
1
) = π
i
b
i
(o
1

) , 1<=i<=N.

Forward recursion:
δ
k
(j) = max P(q
1
… q
k-1
,

q
k
= s
j

,

o
1
o
2
o
k
) =
max
i
[ a
ij
b

j
(o
k
) max P(q
1
… q
k-1
= s
i

,

o
1
o
2
o
k-1
) ] =
max
i
[ a
ij
b
j
(o
k
) δ
k-1
(i) ] , 1<=j<=N, 2<=k<=K.


Termination: choose best path ending at time K
max
i
[ δ
K
(i) ]

Backtrack best path.
This algorithm is similar to the forward recursion of evaluation
problem, with
Σ
replaced by max and additional backtracking.
Viterbi algorithm (2)
Learning problem

The most difficult of the three problems, because there is
no known analytical method that maximizes the joint
probability of the training data

Solved by the Baum-Welch (known as forward backward)
algorithm and EM (Expectation maximization) algorithm

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×