- mse-loss pred target #!key (reduction 'mean)procedure
Mean Squared Error loss with batch support.
- pred
- predictions tensor (any shape)
- target
- target tensor (same shape as pred)
- reduction
- 'mean (average over all elements) or 'sum
For batched inputs (batch_size, ...), computes loss per sample and reduces according to reduction parameter.
; Single sample (define loss (mse-loss predictions targets)) ; Batch of samples (define batch-pred (make-tensor32 pred-data '(32 10))) (define batch-target (make-tensor32 target-data '(32 10))) (define batch-loss (mse-loss batch-pred batch-target reduction: 'mean))