biased_softplus#
- class tensordict.nn.biased_softplus(bias: float, min_val: float = 0.01)#
Bases:
ModuleA softplus shifted so that it returns
biasfor a zero input and stays abovemin_val.The module computes
softplus(x + inv_softplus(bias - min_val)) + min_val.mappings()returns it for the keys"biased_softplus_{bias}"and"biased_softplus_{bias}_{min_val}".- Parameters:
Examples
>>> import torch >>> from tensordict.nn import biased_softplus >>> f = biased_softplus(1.0) >>> f(torch.zeros(2)) tensor([1., 1.])
- forward(x: Tensor) Tensor#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.