Softmax
classin packageklyn.math.nn.activations
public class Softmax<T extends AbstractFloat = Float> extends Layer<T>
Softmax

Stable row-wise normalization of finite logits into class probabilities. Use SparseCategoricalCrossentropy(fromLogits=false) after this activation. A loss configured with fromLogits=true instead requires a linear output.

Example

probabilities = Softmax<Float>().forward(model.predict(xTest))

Properties
Modifier and Type Member Description
public override readonly property displayName
displayName as String
Summary label.
public override readonly property parameterCount
parameterCount as ULong
Softmax has no trainable parameters.
Methods
Modifier and Type Member Description
public override backwardTraining
backwardTraining(context as LayerPass<T>, upstream as NDArray<T>) as LayerGradients<T>
Reuses saved probabilities rather than evaluating exponentials again.
public build
build(inputSize as Long) as Long
Checks and preserves a positive feature width.
public override buildShape
buildShape(inputShape as IList<Long>) as IList<Long>
Validates a vector of class scores.
public override differentiate
differentiate(inputs as NDArray<T>, upstream as NDArray<T>) as LayerGradients<T>
Computes a Jacobian-vector product without materializing a Jacobian.
public override forward
forward(inputs as NDArray<T>) as NDArray<T>
Computes exp(x - max(x)) / sum(exp(x - max(x))) along each row.
public override parameter
parameter(index as Long) as NDArray<T>
Rejects parameter access on this parameter-free activation.