Skip to content
fn

softmin

→Tensor
softmin(input: Tensor, dim: int | None = None, _stacklevel: int = 3, dtype: DTypeLike | None = None)

Softmin — softmax applied to the negation of the input.

Parameters

inputTensor
Input tensor of any shape.
dimint or None= None
Dimension along which softmin is computed.
_stacklevelint= 3
Internal stack level for the implicit-dimension warning.
dtypeDTypeLike or None= None
Target floating-point dtype to cast input to before softmin.

Returns

Tensor

Tensor of the same shape with values summing to 1 along dim.

Notes

softmin(x)i=softmax(−x)i=e−xi∑je−xj\text{softmin}(x)_i = \text{softmax}(-x)_i = \frac{e^{-x_i}}{\sum_j e^{-x_j}}

Examples

>>> import lucid
>>> from lucid.nn.functional import softmin
>>> x = lucid.tensor([[1.0, 2.0, 3.0]])
>>> softmin(x, dim=1)
tensor([[0.6652, 0.2447, 0.09003]])

Used by 1