Table of Contents

Class CTCLossAdapter<T>

Namespace
AiDotNet.LossFunctions
Assembly
AiDotNet.dll

Provides an adapter for using CTCLoss within the LossFunctionBase framework.

public class CTCLossAdapter<T> : LossFunctionBase<T>, ILossFunction<T>

Type Parameters

T

The numeric type used for calculations.

Inheritance
CTCLossAdapter<T>
Implements
Inherited Members
Extension Methods

Constructors

CTCLossAdapter(int, int)

Initializes a new instance of the CTCLossAdapter class.

public CTCLossAdapter(int numClasses, int blankIndex = 0)

Parameters

numClasses int

The number of classes/vocabulary size.

blankIndex int

The blank symbol index.

Methods

CalculateDerivative(Vector<T>, Vector<T>)

Calculates the derivative of the CTC loss.

public override Vector<T> CalculateDerivative(Vector<T> predicted, Vector<T> actual)

Parameters

predicted Vector<T>

The predicted log probabilities as a flattened vector.

actual Vector<T>

The target labels as a flattened vector.

Returns

Vector<T>

The gradient vector with respect to inputs.

CalculateLoss(Vector<T>, Vector<T>)

Adapts the standard loss interface to work with CTC loss.

public override T CalculateLoss(Vector<T> predicted, Vector<T> actual)

Parameters

predicted Vector<T>

The predicted log probabilities as a flattened vector.

actual Vector<T>

The target labels as a flattened vector.

Returns

T

The CTC loss value.