Skip to content

Commit 2bd7e8a

Browse files
authored
Merge pull request #59 from pevnak/pull-request/ea057b05
softplus
2 parents d07ac0b + bdf167d commit 2bd7e8a

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
@@ -116,4 +116,4 @@ softsign(x) = x / (one(x) + abs(x))
116116
117117
See [Deep Sparse Rectifier Neural Networks](http://proceedings.mlr.press/v15/glorot11a/glorot11a.pdf).
118118
"""
119-
softplus(x) = log1p(exp(x))
119+
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
@@ -45,6 +45,8 @@ end
4545
@test gelu(0.0) == 0.0
4646
@test swish(0.0) == 0.0
4747
@test softplus(0.0) log(2.0)
48+
@test softplus(1e8) 1e8
49+
@test softplus(-1e8) 0.0
4850
@test softsign(0.0) == 0.0
4951
@test selu(0.0) == 0.0
5052

0 commit comments

Comments
 (0)