Skip to content

Commit bdf167d

Browse files
pevnakMikeInnes
authored andcommitted
fixed softplus
1 parent 7e8081b commit bdf167d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/activation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ softsign(x) = x / (one(x) + abs(x))
102102
103103
See [Deep Sparse Rectifier Neural Networks](http://proceedings.mlr.press/v15/glorot11a/glorot11a.pdf).
104104
"""
105-
softplus(x) = log1p(exp(x))
105+
softplus(x) = ifelse(x > 0, x + log1p(exp(-x)), log1p(exp(x)))

test/activation.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ end
4444
@test elu(0.0) == 0.0
4545
@test swish(0.0) == 0.0
4646
@test softplus(0.0) log(2.0)
47+
@test softplus(1e8) 1e8
48+
@test softplus(-1e8) 0.0
4749
@test softsign(0.0) == 0.0
4850
@test selu(0.0) == 0.0
4951

0 commit comments

Comments
 (0)