31 #ifndef SHARK_OBJECTIVEFUNCTIONS_LOSS_SQUAREDEPSILONHINGELOSS_H 32 #define SHARK_OBJECTIVEFUNCTIONS_LOSS_SQUAREDEPSILONHINGELOSS_H 61 {
return "SquaredEpsilonHingeLoss"; }
66 SIZE_CHECK(predictions.size1() == labels.size1());
67 SIZE_CHECK(predictions.size2() == labels.size2());
69 return 0.5*sum(max(0.0,sum_columns(
sqr(labels-predictions)) - m_sqrEpsilon));
73 SIZE_CHECK(predictions.size1() == labels.size1());
74 SIZE_CHECK(predictions.size2() == labels.size2());
75 std::size_t numInputs = predictions.size1();
77 gradient.resize(numInputs,predictions.size2());
79 for(std::size_t i = 0; i != numInputs;++i){
80 double sampleLoss = 0.5*std::max(0.0,norm_sqr(row(predictions,i)-row(labels,i))-m_sqrEpsilon);
83 noalias(row(gradient,i)) = row(predictions,i)-row(labels,i);
86 row(gradient,i).clear();