1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #23860 from fengyuentau:fix_overflow_sigmoid_v3.4

dnn: fix overflow in sigmoid layer for 3.4
This commit is contained in:
Alexander Smorkalov
2023-06-23 19:47:42 +03:00
committed by GitHub
@@ -680,7 +680,14 @@ struct SigmoidFunctor : public BaseDefaultFunctor<SigmoidFunctor>
inline float calculate(float x) const
{
return 1.f / (1.f + exp(-x));
float y;
if (x >= 0)
y = 1.f / (1.f + exp(-x));
else {
y = exp(x);
y = y / (1 + y);
}
return y;
}
#ifdef HAVE_HALIDE