73 std::size_t numInputs = labels.size();
78 if(predictions.size2() == 1){
79 for(std::size_t i = 0; i != numInputs;++i){
81 double y = 2.0*labels(i)-1.0;
82 error += std::max(0.0,1.0-y*predictions(i,0));
87 for(std::size_t i = 0; i != numInputs;++i){
89 for(std::size_t o = 0; o != predictions.size2(); ++o){
90 if(o == labels(i))
continue;
91 error += std::max(0.0,2.0 - predictions(i,labels(i))+predictions(i,o));
101 std::size_t numInputs = labels.size();
102 std::size_t outputDim = predictions.size2();
105 gradient.resize(numInputs,outputDim);
110 for(std::size_t i = 0; i != numInputs; ++i){
111 double y = 2.0*labels(i)-1.0;
112 double sampleLoss = std::max(0.0,1.0-y*predictions(i,0));
120 for(std::size_t i = 0; i != numInputs;++i){
122 for(std::size_t o = 0; o != predictions.size2();++o){
123 if( o == labels(i))
continue;
124 double sampleLoss = std::max(0.0, 2.0 - predictions(i,labels(i)) + predictions(i,o));
127 gradient(i,labels(i)) -= 0.5;