class
Softmin
extends
ModuleSoftmin(dim: int | None = None)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)Methods (3)
dunder
__init__
→None__init__(dim: int | None = None)Initialise the Softmin module. See the class docstring for parameter semantics.
fn
forward
→Tensorforward(x: Tensor)Apply the activation function element-wise.
Parameters
inputTensorInput tensor of arbitrary shape.
Returns
TensorOutput tensor of the same shape as input.
fn
extra_repr
→strextra_repr()Return a string representation of the layer's configuration.