Skip to content

Commit 52739d8

Browse files
committed
fix ELU output for nan, test=develop
1 parent a60d93f commit 52739d8

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
@@ -1184,9 +1184,9 @@ struct ELUFunctor : public BaseActivationFunctor<T> {
11841184

11851185
template <typename Device, typename X, typename Out>
11861186
void operator()(Device d, X x, Out out) const {
1187-
out.device(d) = x.cwiseMax(static_cast<T>(0)) +
1188-
(static_cast<T>(alpha) * (x.exp() - static_cast<T>(1)))
1189-
.cwiseMin(static_cast<T>(0));
1187+
out.device(d) =
1188+
(x < static_cast<T>(0))
1189+
.select(static_cast<T>(alpha) * (x.exp() - static_cast<T>(1)), x);
11901190
}
11911191
};
11921192

0 commit comments

Comments
 (0)