Commit c3d1de0a authored by Antoine Cully's avatar Antoine Cully
Browse files

fixed the gradient computation of squared_exp_ard kernel

parent e5ebd35e
......@@ -114,9 +114,11 @@ namespace limbo {
double k = _sf2 * std::exp(-0.5 * z);
grad.head(_input_dim) = (x1 - x2).cwiseQuotient(_ell).array().square() * k;
Eigen::MatrixXd G = -k * (x1 - x2).norm() * _A;
for (size_t j = 0; j < (unsigned int)Params::kernel_squared_exp_ard::k(); ++j)
grad.segment((j + 1) * _input_dim, _input_dim) = G.col(j);
for (size_t j = 0; j < (unsigned int)Params::kernel_squared_exp_ard::k(); ++j) {
Eigen::MatrixXd G = -(x1 - x2).transpose() * _A.col(j) * (x1 - x2).cwiseProduct(_A.col(j)) * k;
grad.segment((j + 1) * _input_dim, _input_dim) = G;
}
grad(grad.size() - 1) = 2 * k;
......
......@@ -188,10 +188,11 @@ BOOST_AUTO_TEST_CASE(test_grad_SE_ARD)
}
// THIS TEST FAILS!
// Params::kernel_squared_exp_ard::set_k(1);
// for (int i = 1; i <= 10; i++) {
// check_kernel<kernel::SquaredExpARD<Params>>(i, 100);
// }
std::cout << "START" << std::endl;
Params::kernel_squared_exp_ard::set_k(1);
for (int i = 1; i <= 10; i++) {
check_kernel<kernel::SquaredExpARD<Params>>(i, 100);
}
}
BOOST_AUTO_TEST_CASE(test_kernel_SE_ARD)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment