oa::ml::loss::multi_margin
Compute the multiclass hinge loss mean_i((1/C) * sum_{j != y_i} max(0, margin - x[i,y_i] + x[i,j])). input is an [N, C] score matrix and target an I32 [N, 1] class-index matrix. The j == y_i hinge term equals margin, so it is subtracted exactly after the full row sum. Errors Returns an error for non-rank-two, empty, or non-FP32 inputs, mismatched targets, or when runtime recording fails.
Function Documentation
Compute the multiclass hinge loss mean_i((1/C) * sum_{j != y_i} max(0, margin - x[i,y_i] + x[i,j])). input is an [N, C] score matrix and target an I32 [N, 1] class-index matrix. The j == y_i hinge term equals margin, so it is subtracted exactly after the full row sum. Errors Returns an error for non-rank-two, empty, or non-FP32 inputs, mismatched targets, or when runtime recording fails.