fn
logsigmoid
→Tensorlogsigmoid(x: Tensor)Numerically stable .
Direct evaluation of underflows once is below machine epsilon (around for float32). Rewriting as matches the same value while staying finite for arbitrarily negative inputs.
Parameters
xTensorInput logits.
Returns
Tensor with the same shape as x, values in
.
Notes
Frequently the building block of binary cross-entropy with logits (BCE-with-logits) and of importance-weighting computations in RL.
Examples
>>> import lucid
>>> from lucid.nn.functional import logsigmoid
>>> x = lucid.tensor([-10.0, 0.0, 10.0])
>>> logsigmoid(x)
Tensor([-10.0000, -0.6931, -0.0000])