Skip to content

Commit 0fdda7a

Browse files
Update src/basicfuns.jl
Co-authored-by: David Widmann <[email protected]>
1 parent 83acf1d commit 0fdda7a

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/basicfuns.jl

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,11 @@ Return `log(exp(x) - 1)` or the “invsoftplus” function. It is the inverse o
262262
logexpm1(x::Real) = x <= 18.0 ? log(_expm1(x)) : x <= 33.3 ? x - exp(-x) : oftype(exp(-x), x)
263263
logexpm1(x::Float32) = x <= 9f0 ? log(expm1(x)) : x <= 16f0 ? x - exp(-x) : oftype(exp(-x), x)
264264

265-
function softplus(x; a::Real=1.0)
266-
if a == 1.0
267-
return log1pexp(x)
268-
end
269-
return log1pexp(a * x) / a
270-
end
265+
softplus(x::Real) = log1pexp(x)
266+
softplus(x::Real, a::Real) = log1pexp(a * x) / a
271267

272-
function invsoftplus(y; a::Real=1.0)
273-
if a == 1.0
274-
return logexpm1(y)
275-
end
276-
return logexpm1(a * y) / a
277-
end
268+
invsoftplus(y::Real) = logexpm1(y)
269+
invsoftplus(y::Real, a::Real) = logexpm1(a * y) / a
278270

279271

280272
"""

0 commit comments

Comments
 (0)