Skip to content

Commit 97ecabf

Browse files
committed
fix ELU output for nan, test=develop
1 parent 29543da commit 97ecabf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

paddle/fluid/operators/activation_op.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1141,9 +1141,9 @@ struct ELUFunctor : public BaseActivationFunctor<T> {
11411141

11421142
template <typename Device, typename X, typename Out>
11431143
void operator()(Device d, X x, Out out) const {
1144-
out.device(d) = x.cwiseMax(static_cast<T>(0)) +
1145-
(static_cast<T>(alpha) * (x.exp() - static_cast<T>(1)))
1146-
.cwiseMin(static_cast<T>(0));
1144+
out.device(d) =
1145+
(x < static_cast<T>(0))
1146+
.select(static_cast<T>(alpha) * (x.exp() - static_cast<T>(1)), x);
11471147
}
11481148
};
11491149

0 commit comments

Comments
 (0)