% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/loss.R
\name{get_constr_output}
\alias{get_constr_output}
\title{Apply hierarchy constraints via max-pooling over descendants (MCM)}
\usage{
get_constr_output(x, R)
}
\arguments{
\item{x}{A \code{torch_tensor} of shape \verb{(batch_size, n_classes)}.}

\item{R}{A \code{torch_tensor} of shape \verb{(1, n_classes, n_classes)} where
\code{R[1, i, j] = 1} iff class \code{i} is a descendant of class \code{j}.}
}
\value{
A \code{torch_tensor} of shape \verb{(batch_size, n_classes)} with constrained outputs.
}
\description{
Given neural network outputs x and ancestor matrix R, enforces that
if a class is predicted positive, all its ancestors must also be positive.
Implements: \verb{final_out[i] = max\{x[j] : R[i,j] = 1\}}
}
