diff options
author | Rasmus Larsen <rmlarsen@google.com> | 2019-03-18 15:51:55 +0000 |
---|---|---|
committer | Rasmus Larsen <rmlarsen@google.com> | 2019-03-18 15:51:55 +0000 |
commit | 5c93b38c5fca514a08084e32feb8a8fb27bf3665 (patch) | |
tree | 67fb1e219c62f52cc5daf8855926c584e47e6789 /Eigen/src/Core | |
parent | 48898a988a5159d2f3c0ff00bd737d17b202e844 (diff) | |
parent | e42f9aa68a53a0a85f7c6ee257c25428c955eea2 (diff) |
Merged in rmlarsen/eigen (pull request PR-618)
Make clipping outside [-18:18] consistent for vectorized and non-vectorized paths of scalar_logistic_op<float>.
Approved-by: Gael Guennebaud <g.gael@free.fr>
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r-- | Eigen/src/Core/functors/UnaryFunctors.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Eigen/src/Core/functors/UnaryFunctors.h b/Eigen/src/Core/functors/UnaryFunctors.h index 1d5eb3678..03f167ac9 100644 --- a/Eigen/src/Core/functors/UnaryFunctors.h +++ b/Eigen/src/Core/functors/UnaryFunctors.h @@ -927,8 +927,9 @@ template <> struct scalar_logistic_op<float> { EIGEN_EMPTY_STRUCT_CTOR(scalar_logistic_op) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float operator()(const float& x) const { - const float one = 1.0f; - return one / (one + numext::exp(-x)); + if (x < -18.0f) return 0.0f; + else if (x > 18.0f) return 1.0f; + else return 1.0f / (1.0f + numext::exp(-x)); } template <typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE |