MeanSquaredError
classin packageklyn.math.nn.losses
public class MeanSquaredError<T extends AbstractFloat = Float> implements RegressionLoss<T>
MeanSquaredError
All Implemented Interfaces: RegressionLoss

Mean squared residual over all samples and output coordinates. The derivative is 2 * (prediction - target) / elementCount. FP64 loss accumulation does not widen the physical tensors. CPU and GPU paths fuse residual calculation, loss reduction and gradient production, without a residual tensor, squared tensor or transfer of whole GPU inputs to the CPU.

Example

result = MeanSquaredError<Float>().compute(predictions, targets)

Constructors
Modifier and Type Member Description
public MeanSquaredError Creates an all-coordinate mean squared error objective.
Methods
Modifier and Type Member Description
public override compute
compute(outputs as NDArray<T>, targets as NDArray<T>, gradientScale as Double = 1.0) as LossResult<T>
Computes MSE and a same-shaped, independent output derivative.