31 #ifndef SHARK_OBJECTIVEFUNCTIONS_LOSS_HUBERLOSS_H 32 #define SHARK_OBJECTIVEFUNCTIONS_LOSS_HUBERLOSS_H 60 {
return "TukeyBiweightLoss"; }
65 SIZE_CHECK(labels.size1() == predictions.size1());
66 SIZE_CHECK(labels.size2() == predictions.size2());
67 std::size_t numInputs = labels.size1();
73 for(std::size_t i = 0; i != numInputs;++i){
74 double norm2 = norm_sqr(row(predictions,i)-row(labels,i));
77 if(norm2 <=
sqr(m_k)){
78 error = norm2/2+
sqr(norm2)/6*(norm2/k4-3/k2);
88 SIZE_CHECK(labels.size1() == predictions.size1());
89 SIZE_CHECK(labels.size2() == predictions.size2());
90 std::size_t numInputs = labels.size1();
91 std::size_t outputDim = predictions.size2();
93 gradient.resize(numInputs,outputDim);
99 for(std::size_t i = 0; i != numInputs;++i){
100 double norm2 = norm_sqr(row(predictions,i)-row(labels,i));
103 if(norm2 <=
sqr(m_k)){
104 error = norm2/2+
sqr(norm2)/6*(norm2/k4-3/k2);
105 noalias(row(gradient,i)) = (1+
sqr(norm2)/k4-2*norm2/k2)*(row(predictions,i)-row(labels,i));