HMM工具箱命令使用说明.docx

HMM工具箱命令使用说明.docx

ID:50825886

大小:440.25 KB

页数:17页

时间:2020-03-15

HMM工具箱命令使用说明.docx_第1页
HMM工具箱命令使用说明.docx_第2页
HMM工具箱命令使用说明.docx_第3页
HMM工具箱命令使用说明.docx_第4页
HMM工具箱命令使用说明.docx_第5页
资源描述:

《HMM工具箱命令使用说明.docx》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、HOWTOUSETHEHMMTOOLBOX(MATLAB)一、离散输出的隐马尔科夫模型(DHMM,HMMwithdiscreteoutputs)最大似然参数估计EM(BaumWelch算法)Thescriptdhmm_em_demo.mgivesanexampleofhowtolearnanHMMwithdiscreteoutputs.LettherebeQ=2statesandO=3outputsymbols.Wecreaterandomstochasticmatricesasfollows.O=3;Q=2;prior0=normalise(rand(Q,1)

2、);transmat0=mk_stochastic(rand(Q,Q));obsmat0=mk_stochastic(rand(Q,O)); Nowwesamplenex=20sequencesoflengthT=10eachfromthismodel,touseastrainingdata.T=10;  %序列长度nex=20; %样本序列数目data=dhmm_sample(prior0,transmat0,obsmat0,nex,T);      Heredatais 20x10.Nowwemakearandomguessastowhattheparame

3、tersare,prior1=normalise(rand(Q,1));%初始状态概率transmat1=mk_stochastic(rand(Q,Q));%初始状态转移矩阵obsmat1=mk_stochastic(rand(Q,O));%初始观测状态到隐藏状态间的概率转移矩阵andimproveourguessusing5iterationsofEM...[LL,prior2,transmat2,obsmat2]=dhmm_em(data,prior1,transmat1,obsmat1,'max_iter',5);%prior2,transmat2,obs

4、mat2为训练好后的初始概率,状态转移矩阵及混合状态概率转移矩阵LL(t)isthelog-likelihoodafteriterationt,sowecanplotthelearningcurve.序列分类Toevaluatethelog-likelihoodofatrainedmodelgiventestdata,proceedasfollows:loglik=dhmm_logprob(data,prior2,transmat2,obsmat2) %HMM测试Note:thediscretealphabetisassumedtobe{1,2,...,O},w

5、hereO=size(obsmat,2).Hencedatacannotcontainany0s.Toclassifyasequenceintooneofkclasses,trainupkHMMs,oneperclass,andthencomputethelog-likelihoodthateachmodelgivestothetestsequence;ifthei'thmodelisthemostlikely,thendeclaretheclassofthesequencetobeclassi.Computingthemostprobablesequence(

6、Viterbi)FirstyouneedtoevaluateB(i,t)=P(y_t

7、Q_t=i)forallt,i:B=multinomial_prob(data,obsmat);Thenyoucanuse[path]=viterbi_path(prior,transmat,B)  二、具有高斯混合输出的隐马尔科夫模型(GHMM,HMMwithmixtureofGaussiansoutputs)MaximumlikelihoodparameterestimationusingEM(BaumWelch)Letusgeneratenex=50vector-valu

8、edsequencesoflengthT=50;eachvectorhassizeO=2.O=2;T=50;nex=50;data=randn(O,T,nex);NowletusefitamixtureofM=2GaussiansforeachoftheQ=2statesusingK-means.M=2;Q=2;left_right=0; prior0=normalise(rand(Q,1));transmat0=mk_stochastic(rand(Q,Q)); [mu0,Sigma0]=mixgauss_init(Q*M,reshape(data,[OT*n

9、ex]),cov_typ

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。