Skip to content
This repository was archived by the owner on Mar 12, 2021. It is now read-only.

Commit f4d3243

Browse files
author
Rodrigo Vargas
committed
Avoid exponential of positive numbers in softplus implementation
1 parent 1f03ea7 commit f4d3243

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/nnlib.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ end
2828
λ * ifelse(x > 0, x/1, α * (exp(x) - 1))
2929
end
3030

31-
@cufunc softplus(x) = log1p(exp(x))
31+
@cufunc softplus(x) = ifelse(x > 0, x + log1p(exp(-x)), log1p(exp(x)))

0 commit comments

Comments
 (0)