klyn.math.nn.losses.ClassificationLoss.compute
method
public override compute(logits as NDArray<T>, labels as NDArray<Int>, gradientScale as Double = 1.0) as LossResult<T>
Description

Computes mean loss and its mean-reduced output derivative.

Parameters
ParameterDescription
logitsMatrix [samples, classes].
labelsInteger vector [samples].
gradientScalePositive finite derivative multiplier; loss remains unscaled.
Returns

Mean loss and gradient, without input mutation.

Example

result = loss.compute(logits, labels)