Table of Contents

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

T

The 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

logProbs Tensor<T>

The log probabilities for each time step and class.

targets int[][]

The target sequence indices.

inputLengths int[]

The actual lengths of input sequences.

targetLengths int[]

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

logProbs Tensor<T>

The log probabilities for each time step and class.

targets int[][]

The target sequence indices.

inputLengths int[]

The actual lengths of input sequences.

targetLengths int[]

The actual lengths of target sequences.

Returns

T

The calculated loss value.