mindspore.ops.CTCGreedyDecoder
- class mindspore.ops.CTCGreedyDecoder(*args, **kwargs)[source]
Performs greedy decoding on the logits given in inputs.
- Parameters
merge_repeated (bool) – If true, merge repeated classes in output. Default: True.
- Inputs:
inputs (Tensor) - The input Tensor must be a 3-D tensor whose shape is (max_time, batch_size, num_classes). num_classes must be num_labels + 1 classes, num_labels indicates the number of actual labels. Blank labels are reserved. Default blank label is num_classes - 1. Data type must be float32 or float64.
sequence_length (Tensor) - A tensor containing sequence lengths with the shape of (batch_size). The type must be int32. Each value in the tensor must be equal to or less than max_time.
- Outputs:
decoded_indices (Tensor) - A tensor with shape of (total_decoded_outputs, 2). Data type is int64.
decoded_values (Tensor) - A tensor with shape of (total_decoded_outputs), it stores the decoded classes. Data type is int64.
decoded_shape (Tensor) - The value of tensor is [batch_size, max_decoded_legth]. Data type is int64.
log_probability (Tensor) - A tensor with shape of (batch_size, 1), containing sequence log-probability, has the same type as inputs.
- Raises
TypeError – If merge_repeated is not a bool.
ValueError – If length of shape of inputs is not equal to 3.
ValueError – If length of shape of sequence_length is not equal to 1.
- Supported Platforms:
Ascend
Examples
>>> inputs = Tensor(np.random.random((2, 2, 3)), mindspore.float32) >>> sequence_length = Tensor(np.array([2, 2]), mindspore.int32) >>> ctc_greedy_decoder = ops.CTCGreedyDecoder() >>> out1, out2, out3, out4 = ctc_greedy_decoder(inputs, sequence_length) >>> print(out1, out2, out3, out4) [[0 0] [0 1] [1 0]] [0 1 0] [2 2] [[-0.7443749] [0.18251707]]