Demo entry 6441274

m

   

Submitted by anonymous on May 27, 2017 at 03:10
Language: Matlab. Code size: 831 Bytes.

%}
%% Definition of the number of components used in GMM.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
clear;clc; 
nbStates = 5 ;

%% 加载关节角度数据集.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Data = importdata('data/gmm_gmr_out/joint.mat');
nbVar = size(Data,1);%返回矩阵的行数,即变量维度
nbCol = max(Data(1,:));%返回每组数据的列数
nbSample = length(find(Data(1,:)==nbCol));%获取训练组数

%% 用k-means聚类初始化GMM参数,用EM算法训练GMM模型,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[Priors, Mu, Sigma] = EM_init_kmeans(Data, nbStates);
[Priors, Mu, Sigma] = EM(Data, Priors, Mu, Sigma);

%% 存储GMM参数
for i=1:nbStates
    Sigma_temp(:,:,i) = Sigma(2:nbVar,2:nbVar,i);
end
Mu_temp =Mu;
Mu_temp(1,:) = [];
saveparam(nbVar, nbStates, Priors, Mu_temp, Sigma_temp);

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).