Library/ManagedCuda/CudaDNN/CTCLossDescriptor.cs
/// <summary>
/// This function returns the ctc costs and gradients, given the probabilities and labels.
/// </summary>
/// <param name="handle">Handle to a previously created cuDNN context.</param>
/// <param name="probsDesc">Handle to the previously initialized probabilities tensor descriptor.</param>
/// <param name="probs">Pointer to a previously initialized probabilities tensor.</param>
/// <param name="labels">Pointer to a previously initialized labels list.</param>
/// <param name="labelLengths">Pointer to a previously initialized lengths list, to walk the above labels list.</param>
/// <param name="inputLengths">Pointer to a previously initialized list of the lengths of the timing steps in each batch.</param>
/// <param name="costs">Pointer to the computed costs of CTC.</param>
/// <param name="gradientsDesc">Handle to a previously initialized gradients tensor descriptor.</param>
/// <param name="gradients">Pointer to the computed gradients of CTC.</param>
/// <param name="algo">Enumerant that specifies the chosen CTC loss algorithm.</param>
/// <param name="workspace">Pointer to GPU memory of a workspace needed to able to execute the specified algorithm.</param>
This function returns the ctc costs and gradients, given the probabilities and labels.
This function returns the ctc costs and gradients given the probabilities and labels .
public void CTCLoss(CudaDNNContext handle,
            TensorDescriptor probsDesc,     
                                        CudaDeviceVariable<double> probs,                          
                                        int[] labels,                          
                                        int[] labelLengths,                    
                                        int[] inputLengths,                    
                                        CudaDeviceVariable<double> costs,                                
                                        TensorDescriptor gradientsDesc, 
                                        CudaDeviceVariable<double> gradients,                      
                                        cudnnCTCLossAlgo algo,                     
                                        CudaDeviceVariable<byte> workspace                            
                                        )
        {
            res = CudaDNNNativeMethods.cudnnCTCLoss(handle.Handle, probsDesc.Desc, probs.DevicePointer, labels, labelLengths, inputLengths, costs.DevicePointer,
                gradientsDesc.Desc, gradients.DevicePointer, algo, _desc, workspace.DevicePointer, workspace.SizeInBytes);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnCTCLoss", res));
            if (res != cudnnStatus.Success) throw new CudaDNNException(res);
        }
public void CTCLoss ( CudaDNNContext handle , TensorDescriptor probsDesc , CudaDeviceVariable < double > probs , int [ ] labels , int [ ] labelLengths , int [ ] inputLengths , CudaDeviceVariable < double > costs , TensorDescriptor gradientsDesc , CudaDeviceVariable < double > gradients , cudnnCTCLossAlgo algo , CudaDeviceVariable < byte > workspace ) { res = CudaDNNNativeMethods . cudnnCTCLoss ( handle . Handle , probsDesc . Desc , probs . DevicePointer , labels , labelLengths , inputLengths , costs . DevicePointer , gradientsDesc . Desc , gradients . DevicePointer , algo , _desc , workspace . DevicePointer , workspace . SizeInBytes ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != cudnnStatus . Success ) throw new CudaDNNException ( res ) ; }
This function returns the ctc costs and gradients, given the probabilities and labels.
This function returns the ctc costs and gradients given the probabilities and labels .
/* Tensor descriptor for probabilities, the dimensions are T,N,A (T is the timing steps, N is the mini batch size, A is the alphabet size)  */ /* probabilities after softmax, in GPU memory */ /* labels, in CPU memory */ /* the length of each label, in CPU memory */ /* the lengths of timing steps in each batch, in CPU memory */ /* the returned costs of CTC, in GPU memory */ /* Tensor descriptor for gradients, the dimensions are T,N,A */ /* the returned CTC gradients, in GPU memory, to compute costs only, set it to NULL */ /* algorithm selected, supported now 0 and 1 */ /* pointer to the workspace, in GPU memory */
handle
CudaDNNContext
Handle to a previously created cuDNN context.
Handle to a previously created cuDNN context .
probsDesc
TensorDescriptor
Handle to the previously initialized probabilities tensor descriptor.
Handle to the previously initialized probabilities tensor descriptor .
probs
CudaDeviceVariable<double>
Pointer to a previously initialized probabilities tensor.
Pointer to a previously initialized probabilities tensor .
labels
int[]
Pointer to a previously initialized labels list.
Pointer to a previously initialized labels list .
labelLengths
int[]
Pointer to a previously initialized lengths list, to walk the above labels list.
Pointer to a previously initialized lengths list to walk the above labels list .
inputLengths
int[]
Pointer to a previously initialized list of the lengths of the timing steps in each batch.
Pointer to a previously initialized list of the lengths of the timing steps in each batch .
costs
CudaDeviceVariable<double>
Pointer to the computed costs of CTC.
Pointer to the computed costs of CTC .
gradientsDesc
TensorDescriptor
Handle to a previously initialized gradients tensor descriptor.
Handle to a previously initialized gradients tensor descriptor .
gradients
CudaDeviceVariable<double>
Pointer to the computed gradients of CTC.
Pointer to the computed gradients of CTC .
algo
cudnnCTCLossAlgo
Enumerant that specifies the chosen CTC loss algorithm.
Enumerant that specifies the chosen CTC loss algorithm .
workspace
CudaDeviceVariable<byte>
Pointer to GPU memory of a workspace needed to able to execute the specified algorithm.
Pointer to GPU memory of a workspace needed to able to execute the specified algorithm .