Realm

oa::ml::loss::margin_ranking

Compute the margin ranking loss mean(max(0, -y * (x1 - x2) + margin)). target is the ±1 direction mask matching the input shapes. Errors Returns an error for mismatched, empty, or non-FP32 inputs, or when runtime recording fails.

FnRust public API

Function Documentation

pub fn margin_ranking( input1: &Matrix, input2: &Matrix, target: &Matrix, margin: f32 ) -> Result<Matrix>
Compute the margin ranking loss mean(max(0, -y * (x1 - x2) + margin)). target is the ±1 direction mask matching the input shapes. Errors Returns an error for mismatched, empty, or non-FP32 inputs, or when runtime recording fails.