Skip to content

Commit 7eea8b8

Browse files
authored
Slightly faster softplus
A few percent faster `softplus` using `relu(x)` instead of `max(x, 0)`. Ref. #347.
1 parent 7087954 commit 7eea8b8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/activations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ julia> softplus(16f0)
615615
16.0f0
616616
```
617617
"""
618-
softplus(x) = log1p(exp(-abs(x))) + max(x, 0)
618+
softplus(x) = log1p(exp(-abs(x))) + relu(x)
619619

620620
"""
621621
logcosh(x)

0 commit comments

Comments
 (0)