diff --git a/modules/ml/src/ann_mlp.cpp b/modules/ml/src/ann_mlp.cpp index 19ee91332..8974b6b89 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;