klyn.math.nn.losses.SupervisedLoss.compute
method
public compute(outputs as NDArray<T>, targets as NDArray<Targets>, gradientScale as Double = 1.0) as LossResult<T>
Description

Computes mean loss and its derivative without changing either input.

Parameters
ParameterDescription
outputsBatched model outputs.
targetsSupervision in the objective's statically declared type.
gradientScalePositive finite derivative multiplier; loss is unscaled.
Returns

Mean scalar objective and a gradient shaped like outputs.

Example

result = loss.compute(predictions, targets, 1.0)