fix overflow

pull/23860/head
fengyuentau 2 years ago
parent 4792837f2e
commit 29388f80a5
  1. 9
      modules/dnn/src/layers/elementwise_layers.cpp

@ -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

Loading…
Cancel
Save