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]- logAlphaOut:
- For Ascend 950PR/Ascend 950DT, [object Object]Atlas A2 training products/Atlas A2 inference products[object Object], and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: The shape is ($N, T, (2 x max(targetLengths) + 8)/8 x 8).
- logAlphaOut:
Returns
[object Object]: 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 value range of
[object Object]is , where indicates the 0th dimension in[object Object], that is, the input length. - The value of
[object Object]must be greater than or equal to 1. - The element in
[object Object]must be less than or equal to the corresponding element 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.
The following example is for reference only. For details, see .
[object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]:
[object Object]Ascend 950PR/Ascend 950DT:
[object Object]