Rate this Page
★ ★ ★ ★ ★

inv_softplus#

tensordict.nn.inv_softplus(bias: float | Tensor) → float | Tensor#

Returns the input of the softplus function that gives bias: log(exp(bias) - 1).

exp(bias) - 1 is clamped to 1e-6 or more, so that the result is finite for bias <= 0.

Parameters:

bias (float or Tensor) – the output of the softplus function.

Returns:

A float for a float input, else a tensor.

Examples

>>> import torch
>>> from tensordict.nn import inv_softplus
>>> inv_softplus(torch.tensor([1.0, 2.0]))
tensor([0.5413, 1.8546])
>>> torch.nn.functional.softplus(inv_softplus(torch.tensor([1.0, 2.0])))
tensor([1., 2.])