From: Tauranis Date: Tue, 12 Apr 2016 11:28:38 +0000 (-0300) Subject: Bug fix for MLP predict for small values to avoid nan responses. X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1912^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=edb6a0e889886c958c908a61a38d8a0953efcf00;p=platform%2Fupstream%2Fopencv.git Bug fix for MLP predict for small values to avoid nan responses. --- diff --git a/modules/ml/src/ann_mlp.cpp b/modules/ml/src/ann_mlp.cpp index 19ee913..8974b6b 100644 --- a/modules/ml/src/ann_mlp.cpp +++ b/modules/ml/src/ann_mlp.cpp @@ -432,8 +432,15 @@ public: double* data = sums.ptr(i); for( j = 0; j < cols; j++ ) { - double t = scale2*(1. - data[j])/(1. + data[j]); - data[j] = t; + if(!cvIsInf(data[j])) + { + double t = scale2*(1. - data[j])/(1. + data[j]); + data[j] = t; + } + else + { + data[j] = -scale2; + } } } break;