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
cb57746d
Commit
cb57746d
authored
Aug 06, 2014
by
Sylvain Calinon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split of the estimateAttractorPath function into productTPGMM.m and GMR.m
parent
191b8988
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
62 deletions
+19
-62
README.md
README.md
+1
-1
demo_DSGMR01.m
demo_DSGMR01.m
+4
-12
estimateAttractorPath.m
estimateAttractorPath.m
+8
-43
productTPGMM.m
productTPGMM.m
+5
-6
reproduction_DS.m
reproduction_DS.m
+1
-0
No files found.
README.md
View file @
cb57746d
...
...
@@ -2,7 +2,7 @@
### Compatibility
The codes
should be compatible
with both Matlab and GNU Octave.
The codes
have been tested
with both Matlab and GNU Octave.
### Usage
...
...
demo_DSGMR01.m
View file @
cb57746d
...
...
@@ -74,9 +74,9 @@ model = init_tensorGMM_timeBased(Data, model); %Initialization
model
=
EM_tensorGMM
(
Data
,
model
);
%% Reproduction with
LQ
R for the task parameters used to train the model
%% Reproduction with
DS-GM
R for the task parameters used to train the model
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp
(
'Reproductions with
LQ
R...'
);
disp
(
'Reproductions with
DS-GM
R...'
);
DataIn
=
[
1
:
s
(
1
)
.
nbData
]
*
model
.
dt
;
for
n
=
1
:
nbSamples
%Retrieval of attractor path through task-parameterized GMR
...
...
@@ -85,9 +85,9 @@ for n=1:nbSamples
end
%% Reproduction with
LQ
R for new task parameters
%% Reproduction with
DS-GM
R for new task parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp
(
'New reproductions with
LQ
R...'
);
disp
(
'New reproductions with
DS-GM
R...'
);
for
n
=
1
:
nbRepros
for
m
=
1
:
model
.
nbFrames
%Random generation of new task parameters
...
...
@@ -178,15 +178,7 @@ for n=1:nbRepros
end
xlabel
(
't'
);
ylabel
(
'|Kp|'
);
%Plot accelerations due to feedback and feedforward terms
figure
;
hold
on
;
n
=
1
;
k
=
1
;
plot
(
r
(
n
)
.
FB
(
k
,:),
'r-'
,
'linewidth'
,
2
);
plot
(
r
(
n
)
.
FF
(
k
,:),
'b-'
,
'linewidth'
,
2
);
legend
(
'ddx feedback'
,
'ddx feedforward'
);
xlabel
(
't'
);
ylabel
([
'ddx_'
num2str
(
k
)]);
%print('-dpng','outTest2.png');
%pause;
%close all;
...
...
estimateAttractorPath.m
View file @
cb57746d
...
...
@@ -17,53 +17,18 @@ function r = estimateAttractorPath(DataIn, model, r)
% pages="3339--3344"
% }
nbData
=
size
(
DataIn
,
2
);
in
=
1
:
size
(
DataIn
,
1
);
out
=
in
(
end
)
+
1
:
model
.
nbVar
;
nbVarOut
=
length
(
out
);
%% GMR to estimate attractor path and associated variations
%% Estimation of the attractor path by Gaussian mixture regression,
%% by using the GMM resulting from the product of linearly transformed Gaussians
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%GMM products
for
i
=
1
:
model
.
nbStates
SigmaTmp
=
zeros
(
model
.
nbVar
);
MuTmp
=
zeros
(
model
.
nbVar
,
1
);
for
m
=
1
:
model
.
nbFrames
MuP
=
r
.
p
(
m
)
.
A
*
model
.
Mu
(:,
m
,
i
)
+
r
.
p
(
m
)
.
b
;
SigmaP
=
r
.
p
(
m
)
.
A
*
model
.
Sigma
(:,:,
m
,
i
)
*
r
.
p
(
m
)
.
A
'
;
SigmaTmp
=
SigmaTmp
+
inv
(
SigmaP
);
MuTmp
=
MuTmp
+
SigmaP
\
MuP
;
end
r
.
Sigma
(:,:,
i
)
=
inv
(
SigmaTmp
);
r
.
Mu
(:,
i
)
=
r
.
Sigma
(:,:,
i
)
*
MuTmp
;
end
[
r
.
Mu
,
r
.
Sigma
]
=
productTPGMM
(
model
,
r
.
p
);
r
.
Priors
=
model
.
Priors
;
r
.
nbStates
=
model
.
nbStates
;
[
r
.
currTar
,
r
.
currSigma
]
=
GMR
(
r
,
DataIn
,
in
,
out
);
%GMR
MuTmp
=
zeros
(
nbVarOut
,
model
.
nbStates
);
for
t
=
1
:
nbData
%Compute activation weight
for
i
=
1
:
model
.
nbStates
r
.
H
(
i
,
t
)
=
model
.
Priors
(
i
)
*
gaussPDF
(
DataIn
(:,
t
),
r
.
Mu
(
in
,
i
),
r
.
Sigma
(
in
,
in
,
i
));
end
r
.
H
(:,
t
)
=
r
.
H
(:,
t
)/
sum
(
r
.
H
(:,
t
));
%Evaluate the current target
currTar
=
zeros
(
nbVarOut
,
1
);
currSigma
=
zeros
(
nbVarOut
,
nbVarOut
);
%Compute expected conditional means
for
i
=
1
:
model
.
nbStates
MuTmp
(:,
i
)
=
r
.
Mu
(
out
,
i
)
+
r
.
Sigma
(
out
,
in
,
i
)/
r
.
Sigma
(
in
,
in
,
i
)
*
(
DataIn
(:,
t
)
-
r
.
Mu
(
in
,
i
));
currTar
=
currTar
+
r
.
H
(
i
,
t
)
*
MuTmp
(:,
i
);
end
%Compute expected conditional covariances
for
i
=
1
:
model
.
nbStates
SigmaTmp
=
r
.
Sigma
(
out
,
out
,
i
)
-
r
.
Sigma
(
out
,
in
,
i
)/
r
.
Sigma
(
in
,
in
,
i
)
*
r
.
Sigma
(
in
,
out
,
i
);
currSigma
=
currSigma
+
r
.
H
(
i
,
t
)
*
(
SigmaTmp
+
MuTmp
(:,
i
)
*
MuTmp
(:,
i
)
'
);
for
j
=
1
:
model
.
nbStates
currSigma
=
currSigma
-
r
.
H
(
i
,
t
)
*
r
.
H
(
j
,
t
)
*
(
MuTmp
(:,
i
)
*
MuTmp
(:,
j
)
'
);
end
end
r
.
currTar
(:,
t
)
=
currTar
;
r
.
currSigma
(:,:,
t
)
=
currSigma
;
end
gaussianProduct
.m
→
productTPGMM
.m
View file @
cb57746d
function
[
Mu
,
Sigma
]
=
gaussianProduct
(
model
,
p
)
% Leonel Rozo, 2014
function
[
Mu
,
Sigma
]
=
productTPGMM
(
model
,
p
)
% Sylvain Calinon, Leonel Rozo, 2014
%
% Compute the product of Gaussians for a task-parametrized model where the
% set of parameters are stored in the variable 'p'.
% GMM products
for
i
=
1
:
model
.
nbStates
%
TP-
GMM products
for
i
=
1
:
model
.
nbStates
% Reallocating
SigmaTmp
=
zeros
(
model
.
nbVar
);
MuTmp
=
zeros
(
model
.
nbVar
,
1
);
...
...
@@ -19,4 +18,4 @@ for i = 1 : model.nbStates
end
Sigma
(:,:,
i
)
=
inv
(
SigmaTmp
);
Mu
(:,
i
)
=
Sigma
(:,:,
i
)
*
MuTmp
;
end
\ No newline at end of file
end
reproduction_DS.m
View file @
cb57746d
...
...
@@ -35,6 +35,7 @@ for t=1:nbData
r
.
Data
(:,
t
)
=
[
DataIn
(:,
t
);
x
];
r
.
ddxNorm
(
t
)
=
norm
(
ddx
);
r
.
kpDet
(
t
)
=
det
(
L
(:,
1
:
nbVarOut
));
r
.
kvDet
(
t
)
=
det
(
L
(:,
nbVarOut
+
1
:
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