Realm

oa::ml::loss::soft_margin

Compute the soft margin loss mean(log(1 + exp(-y * x))). Uses the stable softplus form max(z, 0) + log(1 + exp(-|z|)) with z = -y * x, so large margins saturate without overflow. Errors Returns an error for mismatched, empty, or non-FP32 inputs, or when runtime recording fails.

FnRust public API

Function Documentation

pub fn soft_margin( prediction: &Matrix, target: &Matrix ) -> Result<Matrix>
Compute the soft margin loss mean(log(1 + exp(-y * x))). Uses the stable softplus form max(z, 0) + log(1 + exp(-|z|)) with z = -y * x, so large margins saturate without overflow. Errors Returns an error for mismatched, empty, or non-FP32 inputs, or when runtime recording fails.