Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
pbdlib-matlab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rli
pbdlib-matlab
Commits
ec08be2b
Commit
ec08be2b
authored
Jul 17, 2014
by
Leonel Rozo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New function for initializing a tensorGMM using k-means. Already tested.
parent
46e83db2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
init_tensorGMM_kmeans.m
init_tensorGMM_kmeans.m
+32
-0
No files found.
init_tensorGMM_kmeans.m
0 → 100644
View file @
ec08be2b
function
model
=
init_tensorGMM_kmeans
(
Data
,
model
)
% Author: Leonel Rozo, 2014
% http://programming-by-demonstration.org/LeonelRozo
%
diagRegularizationFactor
=
1E-4
;
%Matricization/flattening of tensor
DataAll
=
reshape
(
Data
,
size
(
Data
,
1
)
*
size
(
Data
,
2
),
size
(
Data
,
3
));
%The function 'kmeans' below is from the Matlab Statistics Toolbox (see note above)
[
Data_id
,
Centers
]
=
kmeans
(
DataAll
'
,
model
.
nbStates
);
% Setting means and covariance matrices
Mu
=
Centers
'
;
Sigma
=
zeros
(
model
.
nbFrames
*
model
.
nbVar
,
model
.
nbFrames
*
model
.
nbVar
,
model
.
nbStates
);
for
i
=
1
:
model
.
nbStates
idtmp
=
find
(
Data_id
==
i
);
model
.
Priors
(
i
)
=
length
(
idtmp
);
Sigma
(:,:,
i
)
=
cov
(
DataAll
(:,
idtmp
)
'
)
+
eye
(
size
(
DataAll
,
1
))
*
diagRegularizationFactor
;
end
model
.
Priors
=
model
.
Priors
/
sum
(
model
.
Priors
);
%Reshape GMM parameters into a tensor
for
m
=
1
:
model
.
nbFrames
for
i
=
1
:
model
.
nbStates
model
.
Mu
(:,
m
,
i
)
=
Mu
((
m
-
1
)
*
model
.
nbVar
+
1
:
m
*
model
.
nbVar
,
i
);
model
.
Sigma
(:,:,
m
,
i
)
=
Sigma
((
m
-
1
)
*
model
.
nbVar
+
1
:
m
*
model
.
nbVar
,(
m
-
1
)
*
model
.
nbVar
+
1
:
m
*
model
.
nbVar
,
i
);
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment