📄 gmmtrain.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head> <title>Description of gmmTrain</title> <meta name="keywords" content="gmmTrain"> <meta name="description" content="gmmTrain: Parameter training for gaussian mixture model (GMM)"> <meta http-equiv="Content-Type" content="text/html; charset=big5"> <meta name="generator" content="m2html © 2003 Guillaume Flandin"> <meta name="robots" content="index, follow"> <link type="text/css" rel="stylesheet" href="../m2html.css"></head><body><a name="_top"></a><div><a href="../index.html">Home</a> > <a href="index.html">dcpr</a> > gmmTrain.m</div><!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td><td align="right"><a href="index.html">Index for dcpr <img alt=">" border="0" src="../right.png"></a></td></tr></table>--><h1>gmmTrain</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>gmmTrain: Parameter training for gaussian mixture model (GMM)</strong></div><h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>function [gmmParam, logProb] = gmmTrain(data, gaussianNumCovType, gmmTrainParam) </strong></div><h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre class="comment"> gmmTrain: Parameter training for gaussian mixture model (GMM)
Usage: function [gmmParam, logProb] = gmmTrain(data, gaussianNumCovType, gmmTrainParam)
data: dim x dataNum matrix where each column is a data point
gaussianNumCovType: A two element vector indicating no. of Gaussians and type of covariance matrix
This function will use gmmInitParamSet() to determine the initial parameters.
On the other hand, this argument could be a gmmParam which specifies the initial parameters.
gmmTrainParam: gmm training parameters (this can be obtained from gmmTrainParamSet.m)
gmmTrainParam.dispOpt: Displaying info during training
gmmTrainParam.useKmeans: Use k-means to find initial centers
gmmTrainParam.maxIteration: Max. number of iterations
gmmTrainParam.minImprove: Min. improvement over the previous iteration
gmmTrainParam.minVariance: Min. variance for each mixture
gmmParam: The final parameters for GMM
logProb: Vector of log probabilities during training
For example, please refer to
1-d example: gmmTrainDemo1d.m
2-d example: gmmTrainDemo2dCovType01.m, gmmTrainDemo2dCovType02.m, and gmmTrainDemo2dCovType03.</pre></div><!-- crossreference --><h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>This function calls:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="gmmEval.html" class="code" title="function [logProb, gaussianProb] = gmmEval(data, gmmParam);">gmmEval</a> gmmEval: Evaluation of a GMM (Gaussian mixture model)</li><li><a href="gmmInitParamSet.html" class="code" title="function gmmParam=gmmInitParamSet(data, gaussianNum, covType, gmmTrainParam);">gmmInitParamSet</a> gmmParamSet: Set a set of initial parameters for GMM</li><li><a href="gmmTrainDemo2dCovType01.html" class="code" title="">gmmTrainDemo2dCovType01</a> Animation of GMM training with covType=1 (isotropic) for 2D data</li><li><a href="gmmTrainParamSet.html" class="code" title="function gmmTrainParam=gmmTrainParamSet">gmmTrainParamSet</a> The following parameters are used for gmmTrain()</li></ul>This function is called by:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="gmmGaussianNumEstimate.html" class="code" title="function [bestMixNum, trainLogProb, testLogProb]=gmmGaussianNumEstimate(trainingData, testData, maxGaussianNum, covType, plotOpt)">gmmGaussianNumEstimate</a> gmmMixNumEstimate: Estimate the number of mixture number of a GMM</li><li><a href="gmmGrowDemo.html" class="code" title="">gmmGrowDemo</a> Example of using gmmGrow.m for growing a GMM (gaussian mixture models).</li><li><a href="gmmMleWrtGaussianNum.html" class="code" title="function [trainLp, testLp]=gmmMleWrtGaussianNum(trainData, testData, vecOfGaussianNum, covType, gmmTrainParam, plotOpt)">gmmMleWrtGaussianNum</a> </li><li><a href="gmmTrainDemo1d.html" class="code" title="">gmmTrainDemo1d</a> Example of using GMM (gaussian mixture model) for 1-D data</li><li><a href="gmmTrainDemo2dCovType01.html" class="code" title="">gmmTrainDemo2dCovType01</a> Animation of GMM training with covType=1 (isotropic) for 2D data</li><li><a href="gmmTrainDemo2dCovType02.html" class="code" title="">gmmTrainDemo2dCovType02</a> Animation of GMM training with covType=2 (diagonal cov. matrix) for 2D data</li><li><a href="gmmTrainDemo2dCovType03.html" class="code" title="">gmmTrainDemo2dCovType03</a> Animation of GMM training with covType=3 (full cov. matrix) for 2D data</li><li><a href="gmmTrainEvalWrtGaussianNum.html" class="code" title="function [gmmData, recogRate1, recogRate2, validMixNumIndex]=gmmTrainEvalWrtGaussianNum(DS, TS, vecOfMixNum, covType, gmmTrainParam)">gmmTrainEvalWrtGaussianNum</a> gmmTrainEvalWrtMixNum: GMM training and test, w.r.t. varying number of mixtures</li></ul><!-- crossreference --><h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><ul style="list-style-image:url(../matlabicon.gif)"><li><a href="#_sub1" class="code">function displayGmm(data, gmmParam)</a></li><li><a href="#_sub2" class="code">function [xData, yData]=halfHeightContour(gaussianParam)</a></li><li><a href="#_sub3" class="code">function selfdemo</a></li></ul><h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [gmmParam, logProb] = gmmTrain(data, gaussianNumCovType, gmmTrainParam)</a>0002 <span class="comment">% gmmTrain: Parameter training for gaussian mixture model (GMM)</span>0003 <span class="comment">% Usage: function [gmmParam, logProb] = gmmTrain(data, gaussianNumCovType, gmmTrainParam)</span>0004 <span class="comment">% data: dim x dataNum matrix where each column is a data point</span>0005 <span class="comment">% gaussianNumCovType: A two element vector indicating no. of Gaussians and type of covariance matrix</span>0006 <span class="comment">% This function will use gmmInitParamSet() to determine the initial parameters.</span>0007 <span class="comment">% On the other hand, this argument could be a gmmParam which specifies the initial parameters.</span>0008 <span class="comment">% gmmTrainParam: gmm training parameters (this can be obtained from gmmTrainParamSet.m)</span>0009 <span class="comment">% gmmTrainParam.dispOpt: Displaying info during training</span>0010 <span class="comment">% gmmTrainParam.useKmeans: Use k-means to find initial centers</span>0011 <span class="comment">% gmmTrainParam.maxIteration: Max. number of iterations</span>0012 <span class="comment">% gmmTrainParam.minImprove: Min. improvement over the previous iteration</span>0013 <span class="comment">% gmmTrainParam.minVariance: Min. variance for each mixture</span>0014 <span class="comment">% gmmParam: The final parameters for GMM</span>0015 <span class="comment">% logProb: Vector of log probabilities during training</span>0016 <span class="comment">%</span>0017 <span class="comment">% For example, please refer to</span>0018 <span class="comment">% 1-d example: gmmTrainDemo1d.m</span>0019 <span class="comment">% 2-d example: gmmTrainDemo2dCovType01.m, gmmTrainDemo2dCovType02.m, and gmmTrainDemo2dCovType03.</span>0020 0021 <span class="comment">% Roger Jang 20000610, 20080726</span>0022 0023 <span class="keyword">if</span> nargin<1, <a href="#_sub3" class="code" title="subfunction selfdemo">selfdemo</a>; <span class="keyword">return</span>; <span class="keyword">end</span>0024 <span class="keyword">if</span> nargin<2, gaussianNumCovType=[3, 1]; <span class="keyword">end</span>0025 <span class="keyword">if</span> nargin<3, gmmTrainParam=<a href="gmmTrainParamSet.html" class="code" title="function gmmTrainParam=gmmTrainParamSet">gmmTrainParamSet</a>; <span class="keyword">end</span>0026 0027 <span class="keyword">if</span> isnumeric(gaussianNumCovType)0028 gaussianNum = gaussianNumCovType(1);0029 covType = gaussianNumCovType(2);0030 <span class="keyword">else</span> <span class="comment">% gaussianNumCovType is in fact the gmmParam.</span>0031 gmmParam = gaussianNumCovType;0032 gaussianNum = length(gmmParam);0033 <span class="keyword">end</span>0034 0035 <span class="comment">% ======= Error checking</span>0036 [dim, dataNum] = size(data);0037 <span class="keyword">if</span> (dataNum<=gaussianNum)0038 error(sprintf(<span class="string">'The given data size is less than the Gaussian number!\n'</span>, dataNum, gaussianNum));0039 <span class="keyword">end</span>0040 range=max(data, [], 2)-min(data, [], 2);0041 <span class="keyword">if</span> any(range==0)0042 fprintf(<span class="string">'Warning: Some of dimensions has the same data. Perhaps you should remove data of the dimension first.\n'</span>);0043 <span class="keyword">elseif</span> max(range)/min(range)>100000044 fprintf(<span class="string">'Warning: max(range)/min(range)=%g>10000 ===> Perhaps you should normalize the data first.\n'</span>, max(range)/min(range));0045 <span class="keyword">end</span>0046 <span class="keyword">if</span> any(isnan(data(:))) | any(isinf(data(:)))0047 error(<span class="string">'Some element is nan or inf in the given data!'</span>);0048 <span class="keyword">end</span>0049 0050 <span class="comment">% ====== Set initial parameters</span>0051 <span class="keyword">if</span> isnumeric(gaussianNumCovType)0052 gmmParam=<a href="gmmInitParamSet.html" class="code" title="function gmmParam=gmmInitParamSet(data, gaussianNum, covType, gmmTrainParam);">gmmInitParamSet</a>(data, gaussianNum, covType, gmmTrainParam);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -