64 SIZE_CHECK(labels.size1() == predictions.size1());
65 SIZE_CHECK(labels.size2() == predictions.size2());
66 std::size_t numInputs = labels.size1();
69 for(std::size_t i = 0; i != numInputs;++i){
70 double norm2 = norm_sqr(row(predictions,i)-row(labels,i));
73 if(norm2 <=
sqr(m_delta)){
77 error += m_delta*std::sqrt(norm2)-0.5*
sqr(m_delta);
84 SIZE_CHECK(labels.size1() == predictions.size1());
85 SIZE_CHECK(labels.size2() == predictions.size2());
86 std::size_t numInputs = predictions.size1();
87 std::size_t outputDim = predictions.size2();
89 gradient.resize(numInputs,outputDim);
91 for(std::size_t i = 0; i != numInputs;++i){
92 double norm2 = norm_sqr(row(predictions,i)-row(labels,i));
95 if(norm2 <=
sqr(m_delta)){
97 noalias(row(gradient,i)) = row(predictions,i)-row(labels,i);
100 double norm = std::sqrt(norm2);
101 error += m_delta*norm-0.5*
sqr(m_delta);
102 noalias(row(gradient,i)) = m_delta/norm*(row(predictions,i)-row(labels,i));