mish_functor_update

pull/17916/head
Sinitsina 4 years ago committed by Dmitry Kurtaev
parent ef1690ef45
commit 0ac2f0e04c
  1. 11
      modules/dnn/src/layers/elementwise_layers.cpp

@ -669,9 +669,14 @@ struct MishFunctor : public BaseFunctor
{
// Use fast approximation introduced in https://github.com/opencv/opencv/pull/17200
float x = srcptr[i];
float eX = exp(std::min(x, 20.f));
float n = (eX + 2) * eX;
dstptr[i] = (x * n) / (n + 2);
if (x >= 8.f)
dstptr[i] = x;
else
{
float eX = exp(x);
float n = (eX + 2) * eX;
dstptr[i] = (x * n) / (n + 2);
}
}
}
}

Loading…
Cancel
Save