Description: Computes the connectionist temporal classification (CTC) loss.
Formula: Let denote the probability that the true character is at time step (typically, is an element of the output matrix after the softmax operation). Let denote the set of all sequences that can be formed from the character set . Each sequence in is called a path and denoted by . The distribution of is given by Equation (1):
Define a many-to-one mapping B: . The conditional probability of is the sum of the probabilities of all paths corresponding to under mapping B, as shown in Equation (2):
The task of finding the label that maximizes is referred to as decoding, as expressed in Equation (3):
When zeroInfinity is True:
Each operator has calls. First, aclnnCtcLossGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation flow. Then, aclnnCtcLoss is called to perform computation.
Parameters
[object Object]- For [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object], the data type cannot be FLOAT16 or BFLOAT16.
- logAlphaOut:
- For [object Object]Atlas inference series products[object Object], [object Object]Atlas training series products[object Object], [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 shape is ().
Returns
aclnnStatus: status code. For details, see .
The first-phase API implements input parameter verification. The following errors may be thrown.
[object Object]
Value range constraints
- The values in
[object Object]must be in the range and must not include the value corresponding to blank, where is the last dimension of[object Object], representing the number of classes. - The values in
[object Object]must be in the range , where is the zeroth dimension of[object Object], representing the input length. - The values in
[object Object]must be greater than or equal to 1. - Each element in
[object Object]must be less than or equal to the corresponding elements in[object Object].
If the first three constraints are violated, out-of-bounds behavior may occur on CPU/GPU, which may cause the computed results of negLogLikelihoodOut and logAlphaOut to differ from the CPU/GPU reference. If the fourth constraint is violated, the computed result of logAlphaOut for the corresponding batch may differ from the CPU/GPU reference.
- The values in
Deterministic computation:
- aclnnCtcLoss defaults to a non-deterministic implementation. You can call aclrtCtxSetSysParamOpt to enable deterministic computation.
For the [object Object]Atlas inference series products[object Object], [object Object]Atlas training series products[object Object], [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 sample code is as follows, which is for reference only. For details, see .
[object Object]