NegativeLogLikelihoodLoss - version 12#
This page documents version 12 of operator NegativeLogLikelihoodLoss. See NegativeLogLikelihoodLoss for the latest version (since version 22).
Domain:
ai.onnxSince version: 12
A NegativeLogLikelihoodLoss operator computes (weighted) negative log likelihood loss. Its “input” tensor has the shape of (N, C, d1, d2, …, dk) where k >= 0. The “input” tensor contains log-probabilities for input[n, :, d_1, d_2,…, d_k] being in a class of [0, C). The operator’s “target” input tensor has the shape of (N, d1, d2, …, dk). It encodes class labels (one of C classes) or it may contain a special value (indicated by an attribute ignore_index) for N x d1 x d2 x … x dk samples. The loss value for input[n, :, d_1, d_2,…d_k] being classified as class c = target[n][d_1][d_2]…[d_k] is computed as:
loss[n][d_1][d_2]...[d_k] = -input[n][c][d_1][d_2]...[d_k].
Inputs
input (T): Input tensor of shape (N, C) or (N, C, d1, d2, …, dk).
target (Tind): Target tensor of shape (N) or (N, d1, d2, …, dk). Target element value shall be in range of [0, C). If ignore_index is specified, it may have a value outside [0, C) and the target values should either be in the range [0, C) or have the value ignore_index.
weight (T): Optional rescaling weight tensor. If given, it has to be a tensor of size C. Otherwise, it is treated as if having all ones.
Outputs
loss (T): The negative log likelihood loss
Attributes
ignore_index (int): Specifies a target value that is ignored and does not contribute to the input gradient. It’s an optional value.
reduction (string): Type of reduction to apply to loss: none, sum, mean (default). ‘none’: the output is the loss for each sample. ‘sum’: the output will be summed. ‘mean’: the sum of the output will be divided by the sum of applied weights.
Type Constraints
T: Constrain input, weight, and output types to floating-point tensors. Allowed types: tensor(double), tensor(float), tensor(float16).
Tind: Constrain target to integer types Allowed types: tensor(int32), tensor(int64).