Softmin activation function.
Applies softmax to the negated input along a specified dimension:
Equivalent to Softmax(-x). The result is a valid probability
distribution where lower values receive higher weight — the
inverse of softmax. Useful when scores represent costs or distances
rather than affinities.
Parameters
dimint or None= NoneThe dimension along which softmin is computed. Default:
None.Notes
- Input: — any shape.
- Output: — same shape as input; values along
dimare non-negative and sum to 1.
Examples
>>> import lucid
>>> import lucid.nn as nn
>>> m = nn.Softmin(dim=-1)
>>> x = lucid.tensor([[1.0, 2.0, 3.0]])
>>> m(x)
tensor([[0.6652, 0.2447, 0.0900]])
>>> # Lowest-cost option gets the highest weight
>>> costs = lucid.tensor([[0.1, 0.5, 0.9]])
>>> weights = nn.Softmin(dim=-1)(costs)
>>> weights.shape
(1, 3)