mirror of
https://github.com/opencv/opencv.git
synced 2025-06-08 01:53:19 +08:00
fix overflow
This commit is contained in:
parent
4792837f2e
commit
29388f80a5
@ -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…
Reference in New Issue
Block a user