fn
softmin
→Tensorsoftmin(x: Tensor, dim: int | None = None)Softmin — softmax applied to the negation of the input.
Useful when small input values should receive high probability, e.g.
when x represents distances or costs and a soft-argmin is needed.
Parameters
xTensorInput tensor of any shape.
dimint= NoneDimension along which softmin is computed. Defaults to the last
dimension (
-1).Returns
TensorTensor of the same shape with values summing to 1 along
dim.
Notes
Exactly equivalent to softmax on the negated input; produced
as a separate function purely for readability when modelling
minimum-cost attention or temperature-scaled retrieval.
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.0900]])