| nnf_mc_loss | R Documentation |
Computes the hierarchy-constrained loss for multi-label classification. Enforces that if a class is predicted positive, all its ancestors must also be positive, using the ancestor matrix R.
nnf_mc_loss(
output,
target,
R,
to_eval = NULL,
criterion = nnf_binary_cross_entropy_with_logits
)
output |
A |
target |
Binary target labels, shape |
R |
Ancestor matrix tensor of shape |
to_eval |
Optional logical tensor of shape |
criterion |
Loss function to apply after constraint propagation.
Default: |
The loss combines constrained outputs differently for positive and negative labels:
For positive labels: uses constrained output of label-weighted predictions
For negative labels: uses constrained raw predictions (penalizes ancestor violations)
A scalar torch_tensor containing the computed loss, or a tensor
of shape (batch_size, n_classes) if reduction = "none".
nn_mc_loss(), get_constr_output()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.