229 ensure_size(result,sizeX1,sizeX2);
232 RealMatrix kernelResult(sizeX1,sizeX2);
233 for (std::size_t i = 0; i !=
m_base.size(); i++){
234 m_base[i].kernel->eval(batchX1, batchX2,kernelResult);
235 result +=
m_base[i].weight*kernelResult;
247 ensure_size(result,sizeX1,sizeX2);
250 InternalState& s = state.
toState<InternalState>();
251 s.resize(sizeX1,sizeX2);
253 for (std::size_t i=0; i !=
m_base.size(); i++){
254 m_base[i].kernel->eval(batchX1,batchX2,s.kernelResults[i],*s.kernelStates[i]);
255 result +=
m_base[i].weight*s.kernelResults[i];
265 RealMatrix
const& coefficients,
271 std::size_t numKernels =
m_base.size();
273 InternalState
const& s = state.
toState<InternalState>();
281 double numeratorSum = sum(coefficients * s.result);
284 double summedK=sum(coefficients * s.kernelResults[i]);
285 gradient(i-1) =
m_base[i].weight * (summedK *
m_weightsum - numeratorSum) / sumSquared;
289 RealVector kernelGrad;
290 for (std::size_t i=0; i != numKernels; i++) {
293 m_base[i].kernel->weightedParameterDerivative(batchX1,batchX2,coefficients,*s.kernelStates[i],kernelGrad);
294 std::size_t n = kernelGrad.size();
295 noalias(subrange(gradient,gradPos,gradPos+n)) = coeff * kernelGrad;
362 RealMatrix
const& coefficientsX2,
365 typename boost::enable_if<boost::is_same<T,RealMatrix > >::type* dummy = 0
367 std::size_t numKernels =
m_base.size();
368 InternalState
const& s = state.
toState<InternalState>();
372 m_base[0].kernel->weightedInputDerivative(batchX1, batchX2, coefficientsX2, *s.kernelStates[0], gradient);
375 for (std::size_t i=1; i != numKernels; i++){
376 m_base[i].kernel->weightedInputDerivative(batchX1, batchX2, coefficientsX2, *s.kernelStates[i], kernelGrad);
378 gradient += coeff * kernelGrad;