Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthias Mayr
limbo
Commits
1850c5cc
Commit
1850c5cc
authored
Jun 25, 2018
by
Konstantinos Chatzilygeroudis
Browse files
Added test for multi-gp recompute
parent
6c826994
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/limbo/model/multi_gp.hpp
View file @
1850c5cc
...
...
@@ -54,8 +54,8 @@ namespace limbo {
/// A wrapper for N-output Gaussian processes.
/// It is parametrized by:
/// - GP class
/// - a kernel function
/// - a mean function
/// - a kernel function
(the same type for all GPs, but can have different parameters)
/// - a mean function
(the same type and parameters for all GPs)
/// - [optional] an optimizer for the hyper-parameters
template
<
typename
Params
,
template
<
typename
,
typename
,
typename
,
typename
>
class
GPClass
,
typename
KernelFunction
,
typename
MeanFunction
,
class
HyperParamsOptimizer
=
limbo
::
model
::
gp
::
NoLFOpt
<
Params
>
>
class
MultiGP
{
...
...
@@ -69,7 +69,6 @@ namespace limbo {
MultiGP
(
int
dim_in
,
int
dim_out
)
:
_dim_in
(
dim_in
),
_dim_out
(
dim_out
),
_mean_function
(
dim_out
)
{
// initialize dim_in models with 1 output
_gp_models
.
resize
(
_dim_out
);
for
(
int
i
=
0
;
i
<
_dim_out
;
i
++
)
{
...
...
src/tests/test_gp.cpp
View file @
1850c5cc
...
...
@@ -1112,3 +1112,45 @@ BOOST_AUTO_TEST_CASE(test_multi_gp_auto)
BOOST_CHECK
(
sigma
(
0
)
<=
2.
*
(
gp
.
gp_models
()[
0
].
kernel_function
().
noise
()
+
1e-8
));
BOOST_CHECK
(
sigma
(
1
)
<=
2.
*
(
gp
.
gp_models
()[
1
].
kernel_function
().
noise
()
+
1e-8
));
}
BOOST_AUTO_TEST_CASE
(
test_multi_gp_recompute
)
{
using
KF_t
=
kernel
::
SquaredExpARD
<
Params
>
;
using
Mean_t
=
mean
::
Constant
<
Params
>
;
using
MultiGP_t
=
model
::
MultiGP
<
Params
,
model
::
GP
,
KF_t
,
Mean_t
>
;
MultiGP_t
gp
;
gp
.
add_sample
(
make_v2
(
1
,
1
),
make_v1
(
2
));
gp
.
add_sample
(
make_v2
(
2
,
2
),
make_v1
(
10
));
// make sure that the observations are properly passed
BOOST_CHECK
(
gp
.
_observations
[
0
](
0
)
==
2.
);
BOOST_CHECK
(
gp
.
_observations
[
1
](
0
)
==
10.
);
// make sure the child GPs have the proper observations
BOOST_CHECK
(
gp
.
gp_models
()[
0
].
_observations
.
row
(
0
)[
0
]
==
(
2.
-
gp
.
mean_function
().
h_params
()[
0
]));
BOOST_CHECK
(
gp
.
gp_models
()[
0
].
_observations
.
row
(
1
)[
0
]
==
(
10.
-
gp
.
mean_function
().
h_params
()[
0
]));
// now change the mean function parameters
gp
.
mean_function
().
set_h_params
(
make_v1
(
2
));
// make sure that the observations are properly passed
BOOST_CHECK
(
gp
.
_observations
[
0
](
0
)
==
2.
);
BOOST_CHECK
(
gp
.
_observations
[
1
](
0
)
==
10.
);
// make sure the child GPs do not have the proper observations
BOOST_CHECK
(
!
(
gp
.
gp_models
()[
0
].
_observations
.
row
(
0
)[
0
]
==
(
2.
-
gp
.
mean_function
().
h_params
()[
0
])));
BOOST_CHECK
(
!
(
gp
.
gp_models
()[
0
].
_observations
.
row
(
1
)[
0
]
==
(
10.
-
gp
.
mean_function
().
h_params
()[
0
])));
// recompute the GP
gp
.
recompute
();
// make sure that the observations are properly passed
BOOST_CHECK
(
gp
.
_observations
[
0
](
0
)
==
2.
);
BOOST_CHECK
(
gp
.
_observations
[
1
](
0
)
==
10.
);
// make sure the child GPs have the proper observations
BOOST_CHECK
(
gp
.
gp_models
()[
0
].
_observations
.
row
(
0
)[
0
]
==
(
2.
-
gp
.
mean_function
().
h_params
()[
0
]));
BOOST_CHECK
(
gp
.
gp_models
()[
0
].
_observations
.
row
(
1
)[
0
]
==
(
10.
-
gp
.
mean_function
().
h_params
()[
0
]));
}
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