SoftmaxCrossEntropyLoss

Description

Is a loss function used to calculate the SoftmaxCrossEntropy loss between scores and labels.

Input

scores: tensor of type float16, float, or double, with shape [N, C] or [N, C, D1, D2, ..., Dk], where N indicates batch and C indicates class.

labels: tensor of type int32 or int64, with the same shape as scores.

weights: tensor of type float16 or float, with shape [C], used to adjust the loss weight of different classes.

Attribute

ignore_index: int, used to specify a target value, which will be ignored and will not affect gradient calculation.

reduction: string, reduction type of the loss. The value can be none, sum, or mean.

Output

output: output tensor of the identical data type as scores. If reduction is set to none, the output shape is the same as the values of scores and labels. Otherwise, the output shape is a scalar.

log_prob: tensor of the identical data type as scores. It indicates the logarithm of the probability value output by Softmax.

ONNX Opset Support

Opset v12/v13/v14/v15/v16/v17/v18