Interface ISequenceLossFunction<T>
- Namespace
- AiDotNet.Interfaces
- Assembly
- AiDotNet.dll
Interface for sequence loss functions that operate on variable-length sequences.
public interface ISequenceLossFunction<T>
Type Parameters
TThe numeric type used for calculations.
Methods
CalculateGradient(Tensor<T>, int[][], int[], int[])
Calculates the gradient of the loss with respect to the inputs.
Tensor<T> CalculateGradient(Tensor<T> logProbs, int[][] targets, int[] inputLengths, int[] targetLengths)
Parameters
logProbsTensor<T>The log probabilities for each time step and class.
targetsint[][]The target sequence indices.
inputLengthsint[]The actual lengths of input sequences.
targetLengthsint[]The actual lengths of target sequences.
Returns
- Tensor<T>
The gradient tensor with same shape as inputs.
CalculateLoss(Tensor<T>, int[][], int[], int[])
Calculates the loss for sequence data.
T CalculateLoss(Tensor<T> logProbs, int[][] targets, int[] inputLengths, int[] targetLengths)
Parameters
logProbsTensor<T>The log probabilities for each time step and class.
targetsint[][]The target sequence indices.
inputLengthsint[]The actual lengths of input sequences.
targetLengthsint[]The actual lengths of target sequences.
Returns
- T
The calculated loss value.