37 #ifndef SHARK_ALGORITHMS_KERNELSGDTRAINER_H 38 #define SHARK_ALGORITHMS_KERNELSGDTRAINER_H 89 template <
class InputType,
class CacheType =
float>
138 {
return "KernelSGDTrainer"; }
148 RealMatrix& alpha = model.
alpha();
157 double alphaScale = 1.0;
158 std::size_t iterations;
159 if(
m_epochs == 0) iterations = std::max(10 * ell, std::size_t(std::ceil(
m_C * ell)));
163 RealVector f_b(classes, 0.0);
164 RealVector derivative(classes, 0.0);
167 blas::vector<QpFloatType> kernelRow(ell, 0);
168 for(std::size_t iter = 0; iter < iterations; iter++)
174 const double eta = 1.0 / (lambda * (iter + ell));
178 noalias(f_b) = alphaScale * prod(trans(alpha), kernelRow);
186 alphaScale = (ell - 1.0) / (ell + iter);
188 noalias(row(alpha, b)) -= (eta / alphaScale) * derivative;
249 m_C = newParameters.back();