mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-05-01 16:24:28 +08:00
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>
This commit is contained in:
commit
5c93b38c5f
@ -927,8 +927,9 @@ template <>
|
|||||||
struct scalar_logistic_op<float> {
|
struct scalar_logistic_op<float> {
|
||||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_logistic_op)
|
EIGEN_EMPTY_STRUCT_CTOR(scalar_logistic_op)
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float operator()(const float& x) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float operator()(const float& x) const {
|
||||||
const float one = 1.0f;
|
if (x < -18.0f) return 0.0f;
|
||||||
return one / (one + numext::exp(-x));
|
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
|
template <typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user