📄 labman2.tex
字号:
\documentclass[twoside,a4paper,titlepage]{article}\usepackage{array,amsmath,amssymb,rotating,epsfig,fancyheadings}\newcommand{\mat}[1]{{\tt >> #1} \\}\newcommand{\com}[1]{{\tt #1}}\newcommand{\expl}[1]{%\begin{turn}{180}%\parbox{\textwidth}{\em #1}%\end{turn}%}\newcommand{\tit}[1]{{\noindent \bf #1 \\}}\newcommand{\tab}{\hspace{1em}}\newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp}\newcommand{\RR}{\PBS\raggedright\hspace{0pt}}\newcommand{\RL}{\PBS\raggedleft\hspace{0pt}}\newcommand{\CC}{\PBS\centering\hspace{0pt}}\setlength{\hoffset}{-1in}\setlength{\voffset}{-1in}\setlength{\topskip}{0cm}\setlength{\headheight}{0cm}\setlength{\headsep}{0cm}\setlength{\textwidth}{16cm}\setlength{\evensidemargin}{2.5cm}\setlength{\oddsidemargin}{2.5cm}\setlength{\textheight}{24.7cm}\setlength{\topmargin}{1.5cm}\setlength{\headheight}{0.5cm}\setlength{\headsep}{0.5cm}\pagestyle{fancyplain}\begin{document}\begin{titlepage}\setcounter{page}{-1}\centerline{Ecole Polytechnique F\'ed\'erale de Lausanne}\vspace{5cm}\begin{center}\hugeLab session 2\,: \\Introduction to Hidden Markov Models\end{center}\vfill\centerline{\includegraphics[width=7cm]{hmmcover.eps.gz}}\vfill\noindent\begin{tabular}{lll}Course\,: & Speech processing and speech recognition & \\& & \\Teacher\,: & Prof. Herv\'e Bourlard \hspace{1cm} & {\tt bourlard@idiap.ch} \\& & \\Assistants\,: & Sacha Krstulovi\'c & {\tt sacha@idiap.ch}\\ & Mathew Magimai-Doss & {\tt mathew@idiap.ch} \end{tabular}\end{titlepage}\thispagestyle{empty}%%%%%%%%%%%%%%%%%%\section*{Guidelines}%%%%%%%%%%%%%%%%%%The following lab manual is structured as follows\,:\begin{itemize}\item each section corresponds to a theme\item each subsection corresponds to a separate experiment.\end{itemize}The subsections begin with useful formulas and definitions that will be putin practice during the experiments. These are followed by the descriptionof the experiment and by an example of how to realize it in {\sc Matlab}.If you follow the examples literally, you will be able to progress into thelab session without worrying about the experimental implementationdetails. If you have ideas for better {\sc Matlab} implementations, you arewelcome to put them in practice provided you don't loose too much time\,:remember that a lab session is no more than 3 hours long.The subsections also contain questions that you should think about.Corresponding answers are given right after, in case of problem. You canread them right after the question, {\em but}\,: the purpose of this lab isto make you\medskip\centerline{\LARGE \bf Think !}\medskipIf you get lost with some of the questions or some of the explanations, DOASK the assistants or the teacher for help\,: they are here to make the courseunderstood. There is no such thing as a stupid question, and the onlyobstacle to knowledge is laziness.\bigskipHave a nice lab;\hfill Teacher \& Assistants \hspace{2cm}\vfill%%%%%%%%%%%%%%%%%%\section*{Before you begin...}%%%%%%%%%%%%%%%%%%If this lab manual has been handed to you as a hardcopy\,:\begin{enumerate}\item get the lab package from \\ \hspace{2cm}{\tt ftp.idiap.ch/pub/sacha/labs/Session2.tgz}\item un-archive the package\,: \\ {\tt \% gunzip Session2.tgz \\ \% tar xvf Session2.tar}\item change directory\,: \\ {\tt \% cd session2}\item start {\sc Matlab}\,: \\ {\tt \% matlab }\end{enumerate}Then go on with the experiments...\vspace{1cm}{\scriptsize\noindentThis document was created by\,: Sacha Krstulovi\'c ({\tt sacha@idiap.ch}).\noindentThis document is currently maintained by\,: Sacha Krstulovi\'c ({\tt sacha@idiap.ch}). Last modification on \today.\noindentThis document is part of the package {\tt Session2.tgz} available by ftp as\,: {\tt ftp.idiap.ch/pub/sacha/labs/Session2.tgz} .}\clearpage\tableofcontents\bigskip%\clearpage%%%%%%%%%%%%%%%%%%\section{Preamble}%%%%%%%%%%%%%%%%%%\subsubsection*{Useful formulas and definitions\,:}\begin{itemize}%\item[-] a {\em Markov chain} or {\em process} is a sequence of events,usually called {\em states}, the probability of each of which is dependentonly on the event immediately preceding it.%\item[-] a {\em Hidden Markov Model} (HMM) represents stochastic sequencesas Markov chains where the states are not directly observed, but areassociated with a probability density function (pdf). The generation of arandom sequence is then the result of a random walk in the chain (i.e. thebrowsing of a random sequence of states $Q=\{q_1,\cdots q_K\}$) and of adraw (called an {\em emission}) at each visit of a state.The sequence of states, which is the quantity of interest in speechrecognition and in most of the other pattern recognition problems, can beobserved only {\em through} the stochastic processes defined into eachstate (i.e. you must know the parameters of the pdfs of each state beforebeing able to associate a sequence of states $Q=\{q_1,\cdots q_K\}$ to asequence of observations $X=\{x_1,\cdots x_K\}$). The true sequence ofstates is therefore {\em hidden} by a first layer of stochastic processes.HMMs are {\em dynamic models}, in the sense that they are specificallydesigned to account for some macroscopic structure of the randomsequences. In the previous lab, concerned with {\em Gaussian Statistics andStatistical Pattern Recognition}, random sequences of observations wereconsidered as the result of a series of {\em independent} draws in one orseveral Gaussian densities. To this simple statistical modeling scheme,HMMs add the specification of some {\em statistical dependence} between the(Gaussian) densities from which the observations are drawn.\item[-] {\em HMM terminology} \,:\begin{itemize}\item the {\em emission probabilities} are the pdfs that characterize eachstate $q_i$, i.e. $p(x|q_i)$. To simplify the notations, they will bedenoted $b_i(x)$. For practical reasons, they are usually Gaussian orcombinations of Gaussians, but the states could be parameterized in termsof any other kind of pdf (including discrete probabilities and artificialneural networks).\item the {\em transition probabilities} are the probability to go from astate $i$ to a state $j$, i.e. $P(q_j|q_i)$. They are stored in matriceswhere each term $a_{ij}$ denotes a probability $P(q_j|q_i)$.\item {\em non-emitting initial and final states}\,: if a random sequence$X=\{x_1,\cdots x_K\}$ has a finite length $K$, the fact that the sequencebegins or ends has to be modeled as two additional discrete events. InHMMs, this corresponds to the addition of two {\em non-emitting states},the initial state and the final state. Since their role is just to modelthe ``start'' or ``end'' events, they are not associated with some emissionprobabilities.The transitions starting from the initial state correspond to the modelingof an {\em initial state distribution} $P(I|q_j)$, which indicates theprobability to start the state sequence with the emitting state $q_j$.The final state usually has only one non-null transition that loops ontoitself with a probability of $1$ (it is an {\em absorbent state}), so thatthe state sequence gets ``trapped'' into it when it is reached.\item {\em ergodic versus left-right HMMs}\,: a HMM allowing fortransitions from any emitting state to any other emitting state is calledan {\em ergodic HMM}. Alternately, an HMM where the transitions only gofrom one state to itself or to a unique follower is called a {\emleft-right HMM}.\end{itemize}\end{itemize}\subsubsection*{Values used throughout the experiments\,:}The following 2-dimensional Gaussian densities will be used to modelsimulated vowel observations, where the considered features are the twofirst formants\,:\begin{tabular}{>{\CC}m{10em}>{\CC}m{12em}>{\CC}m{12em}}Density ${\cal N}_{/a/}$\,: &\[ \mu_{/a/} = \left[\begin{array}{r} 730 \\ 1090 \end{array}\right] \] &\[ \Sigma_{/a/} = \left[\begin{array}{rr} 1625 & 5300 \\ 5300 & 53300 \end{array}\right] \] \\Density ${\cal N}_{/e/}$\,: &\[ \mu_{/e/} = \left[\begin{array}{r} 530 \\ 1840 \end{array}\right] \] &\[ \Sigma_{/e/} = \left[\begin{array}{rr} 15025 & 7750 \\ 7750 & 36725 \end{array}\right] \] \\Density ${\cal N}_{/i/}$\,: &\[ \mu_{/i/} = \left[\begin{array}{r} 270 \\ 2290 \end{array}\right] \] &\[ \Sigma_{/i/} = \left[\begin{array}{rr} 2525 & 1200 \\ 1200 & 36125 \end{array}\right] \] \\Density ${\cal N}_{/o/}$\,: &\[ \mu_{/o/} = \left[\begin{array}{r} 570 \\ 840 \end{array}\right] \] &\[ \Sigma_{/o/} = \left[\begin{array}{rr} 2000 & 3600 \\ 3600 & 20000 \end{array}\right] \] \\Density ${\cal N}_{/y/}$\,: &\[ \mu_{/y/} = \left[\begin{array}{r} 440 \\ 1020 \end{array}\right] \] &\[ \Sigma_{/y/} = \left[\begin{array}{rr} 8000 & 8400 \\ 8400 & 18500 \end{array}\right] \] \\\end{tabular}\noindent (Those densities have been used in the previous lab session.)They will be combined into Markov Models that will be used to model someobservation sequences. The resulting HMMs are described intable~\ref{tab:models}.\begin{table}[p]\vspace{-3mm}\setlength{\arraycolsep}{2pt}\renewcommand{\arraystretch}{1.5}\begin{tabular}{>{\CC}m{0.25\textwidth}>{\CC\scriptsize}m{0.26\textwidth}>{\CC}m{0.45\textwidth}} \bf Emission probabilities & {\normalsize \bf Transition matrix} & \bf Sketch of the model \vspace{2mm} \\ \begin{tabular}{>{\hspace{-2em}}l}{\bf HMM1}\,: \\$\bullet$ state 1: initial state \\$\bullet$ state 2: Gaussian ${\cal N}_{/a/}$ \\$\bullet$ state 3: Gaussian ${\cal N}_{/i/}$ \\$\bullet$ state 4: Gaussian ${\cal N}_{/y/}$ \\$\bullet$ state 5: final state \end{tabular} & \[ \left[\begin{array}{lllll} 0.0 & \bf 1.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & \bf 0.4 & \bf 0.3 & \bf 0.3 & 0.0 \\ 0.0 & \bf 0.3 & \bf 0.4 & \bf 0.3 & 0.0 \\ 0.0 & \bf 0.3 & \bf 0.3 & \bf 0.3 & \bf 0.1 \\ 0.0 & 0.0 & 0.0 & 0.0 & \bf 1.0 \end{array}\right] \] & \input{hmm1.pstex_t} \\ % \begin{tabular}{>{\hspace{-2em}}l}{\bf HMM2}\,: \\$\bullet$ state 1: initial state \\$\bullet$ state 2: Gaussian ${\cal N}_{/a/}$ \\$\bullet$ state 3: Gaussian ${\cal N}_{/i/}$ \\$\bullet$ state 4: Gaussian ${\cal N}_{/y/}$ \\$\bullet$ state 5: final state \end{tabular} & \[ \left[\begin{array}{lllll} 0.0 & \bf 1.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & \bf 0.95 & \bf 0.025 & \bf 0.025 & 0.0 \\ 0.0 & \bf 0.025 & \bf 0.95 & \bf 0.025 & 0.0 \\ 0.0 & \bf 0.02 & \bf 0.02 & \bf 0.95 & \bf 0.01 \\ 0.0 & 0.0 & 0.0 & 0.0 & \bf 1.0 \end{array}\right] \] & \input{hmm2.pstex_t} \\ % \begin{tabular}{>{\hspace{-2em}}l}{\bf HMM3}\,: \\$\bullet$ state 1: initial state \\$\bullet$ state 2: Gaussian ${\cal N}_{/a/}$ \\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -