wolffd@0
|
1 function [initState, transmat, mu, Sigma] = gausshmm_train_observed(obsData, hiddenData, ...
|
wolffd@0
|
2 nstates, varargin)
|
wolffd@0
|
3 % GAUSSHMM_TRAIN_OBSERVED Estimate params of HMM with Gaussian output from fully observed sequences
|
wolffd@0
|
4 % [initState, transmat, mu, Sigma] = gausshmm_train_observed(obsData, hiddenData, nstates,...)
|
wolffd@0
|
5 %
|
wolffd@0
|
6 % INPUT
|
wolffd@0
|
7 % If all sequences have the same length
|
wolffd@0
|
8 % obsData(:,t,ex)
|
wolffd@0
|
9 % hiddenData(ex,t) - must be ROW vector if only one sequence
|
wolffd@0
|
10 % If sequences have different lengths, we use cell arrays
|
wolffd@0
|
11 % obsData{ex}(:,t)
|
wolffd@0
|
12 % hiddenData{ex}(t)
|
wolffd@0
|
13 %
|
wolffd@0
|
14 % Optional argumnets
|
wolffd@0
|
15 % dirichletPriorWeight - for smoothing transition matrix counts
|
wolffd@0
|
16 %
|
wolffd@0
|
17 % Optional parameters from mixgauss_Mstep:
|
wolffd@0
|
18 % 'cov_type' - 'full', 'diag' or 'spherical' ['full']
|
wolffd@0
|
19 % 'tied_cov' - 1 (Sigma) or 0 (Sigma_i) [0]
|
wolffd@0
|
20 % 'clamped_cov' - pass in clamped value, or [] if unclamped [ [] ]
|
wolffd@0
|
21 % 'clamped_mean' - pass in clamped value, or [] if unclamped [ [] ]
|
wolffd@0
|
22 % 'cov_prior' - Lambda_i, added to YY(:,:,i) [0.01*eye(d,d,Q)]
|
wolffd@0
|
23 %
|
wolffd@0
|
24 % Output
|
wolffd@0
|
25 % mu(:,q)
|
wolffd@0
|
26 % Sigma(:,:,q)
|
wolffd@0
|
27
|
wolffd@0
|
28 [dirichletPriorWeight, other] = process_options(...
|
wolffd@0
|
29 varargin, 'dirichletPriorWeight', 0);
|
wolffd@0
|
30
|
wolffd@0
|
31 [transmat, initState] = transmat_train_observed(hiddenData, nstates, ...
|
wolffd@0
|
32 'dirichletPriorWeight', dirichletPriorWeight);
|
wolffd@0
|
33
|
wolffd@0
|
34 % convert to obsData(:,t*nex)
|
wolffd@0
|
35 if ~iscell(obsData)
|
wolffd@0
|
36 [D T Nex] = size(obsData);
|
wolffd@0
|
37 obsData = reshape(obsData, D, T*Nex);
|
wolffd@0
|
38 else
|
wolffd@0
|
39 obsData = cat(2, obsData{:});
|
wolffd@0
|
40 hiddenData = cat(2,hiddenData{:});
|
wolffd@0
|
41 end
|
wolffd@0
|
42 [mu, Sigma] = condgaussTrainObserved(obsData, hiddenData(:), nstates, varargin{:});
|
wolffd@0
|
43
|
wolffd@0
|
44
|