Realm

oa::ml::loss::multi_label_soft_margin

Compute the multi-label soft margin loss (binary cross-entropy with logits, averaged over classes then batch). input is an [N, C] logit matrix and target an [N, C] 0/1 mask. weight optionally scales each class term by an [N, C]-broadcastable weight matrix. Uses the stable softplus form so large logits do not overflow. Errors Returns an error for mismatched, empty, non-rank-two, or non-FP32 inputs, or when runtime recording fails.

FnRust public API

Function Documentation

pub fn multi_label_soft_margin( input: &Matrix, target: &Matrix, weight: Option<&Matrix> ) -> Result<Matrix>
Compute the multi-label soft margin loss (binary cross-entropy with logits, averaged over classes then batch). input is an [N, C] logit matrix and target an [N, C] 0/1 mask. weight optionally scales each class term by an [N, C]-broadcastable weight matrix. Uses the stable softplus form so large logits do not overflow. Errors Returns an error for mismatched, empty, non-rank-two, or non-FP32 inputs, or when runtime recording fails.