Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tfb_softplus

Computes Y = g(X) = Log[1 + exp(X)]


Description

The softplus Bijector has the following two useful properties:

  • The domain is the positive real numbers

  • softplus(x) approx x, for large x, so it does not overflow as easily as the Exp Bijector.

Usage

tfb_softplus(hinge_softness = NULL, validate_args = FALSE, name = "softplus")

Arguments

hinge_softness

Nonzero floating point Tensor. Controls the softness of what would otherwise be a kink at the origin. Default is 1.0.

validate_args

Logical, default FALSE. Whether to validate input with asserts. If validate_args is FALSE, and the inputs are invalid, correct behavior is not guaranteed.

name

name prefixed to Ops created by this class.

Details

The optional nonzero hinge_softness parameter changes the transition at zero. With hinge_softness = c, the bijector is:

f_c(x) := c * g(x / c) = c * Log[1 + exp(x / c)].
```

For large x >> 1,

```
c * Log[1 + exp(x / c)] approx c * Log[exp(x / c)] = x
```

so the behavior for large x is the same as the standard softplus.
As c > 0 approaches 0 from the right, f_c(x) becomes less and less soft,
approaching max(0, x).
* c = 1 is the default.
* c > 0 but small means f(x) approx ReLu(x) = max(0, x).
* c < 0 flips sign and reflects around the y-axis: f_{-c}(x) = -f_c(-x).
* c = 0 results in a non-bijective transformation and triggers an exception.
Note: log(.) and exp(.) are applied element-wise but the Jacobian is a reduction over the event space.

[1 + exp(x / c)]: R:1%20+%20exp(x%20/%20c)
[1 + exp(x / c)]: R:1%20+%20exp(x%20/%20c)
[exp(x / c)]: R:exp(x%20/%20c)

Value

a bijector instance.

See Also


tfprobability

Interface to 'TensorFlow Probability'

v0.11.0.0
Apache License (>= 2.0)
Authors
Sigrid Keydana [aut, cre], Daniel Falbel [ctb], Kevin Kuo [ctb] (<https://orcid.org/0000-0001-7803-7901>), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.