- Description: Performs backpropagation of the negative log-likelihood loss function.
- Formula:
reduction=mean:
reduction=sum:
reduction=none:
Each operator has calls. First, aclnnNLLLossBackwardGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnNLLLossBackward is called to perform computation.
[object Object][object Object]
Parameters:
gradOutput (aclTensor*, compute input): gradient of the forward output, gradOutput in the formula, aclTensor on the device. are supported. The can be ND. The shape is (N), one-dimensional (with only one element), or ().
- Data type:
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, or BFLOAT16.
- shape:
- When
[object Object]is 0 and the shape of[object Object]is (N, C), the shape can be (N). - When
[object Object]is 0 and the shape of[object Object]is (C), the shape can be one-dimensional (with only one element) or (). - When
[object Object]is not 0, the shape can be one-dimensional (with only one element) or ().
- When
- Data type:
self (aclTensor*, compute input): aclTensor on the device. are supported. The can be ND. The data type is the same as that of
[object Object], and the shape is the same as that of[object Object].- Data type:
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, or BFLOAT16.
- shape:
- The shape is (N, C) or (C), where N indicates the batch size and C indicates the number of classes.
- When the shape of
[object Object]is (N), the shape of[object Object]must be (N, C). - When the shape of
[object Object]is (), the shape of[object Object]must be (C).
- Data type:
target (aclTensor*, compute input): aclTensor on the device, real label, target in the formula. The data type can be INT64, UINT8, or INT32. are supported. The can be ND. The shape is (N) or (), where the value range of each element is [0, C – 1].
weight (aclTensor*, compute input): aclTensor on the device, w in the formula. It indicates the weight of each class. are supported. The can be ND. The shape is (C).
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, or BFLOAT16.
reduction (int64_t*, compute input): integer on the host, reduction in the formula. It specifies the calculation method of the loss function. The value can be
[object Object]. none indicates that no reduction is applied; mean indicates that the sum of the output will be divided by the number of elements in the output; sum indicates that the output will be summed.ignoreIndex (int64_t*, compute input): integer on the host. It specifies a target value that is ignored and does not affect the input gradient.
totalWeight (aclTensor*, compute input): aclTensor on the device, totalWeight in the formula. When
[object Object]is set to[object Object],[object Object]is the[object Object]obtained from the corresponding position through[object Object], with the[object Object]corresponding to[object Object]removed and the remaining[object Object]summed. When[object Object]is set to other values, this parameter is not processed by default. The can be ND. The shape is (1,). The data type is the same as that of the input parameter[object Object].- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, or BFLOAT16.
out (aclTensor*, compute output): aclTensor on the device. are supported. The can be ND. The shape must be the same as that of the input parameter
[object Object].- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, or BFLOAT16.
workspaceSize (uint64_t*, output): size of the workspace to be allocated on the device.
executor (aclOpExecutor**, output): operator executor, containing the operator computation process.
Returns:
Parameters:
- workspace (void*, input): address of the workspace to be allocated on the device.
- workspaceSize (uint64_t, input): size of the workspace to be allocated on the device, which is obtained by the first-phase API aclnnNLLLossBackwardGetWorkspaceSize.
- executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
- stream (aclrtStream, input): stream for executing the task.
Returns:
- Deterministic compute:
- aclnnNLLLossBackward defaults to a deterministic implementation.
The following example is for reference only. For details, see .