Table of Contents

Class ScaleInvariantDepthLoss<T>

Namespace
AiDotNet.LossFunctions
Assembly
AiDotNet.dll

Scale-invariant depth loss function for depth estimation training.

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

Type Parameters

T

The numeric type used for calculations.

Inheritance
ScaleInvariantDepthLoss<T>
Implements
Inherited Members
Extension Methods

Remarks

For Beginners: This loss function is specifically designed for training depth estimation models. It handles the inherent scale ambiguity in monocular depth estimation by focusing on the relative depth relationships between pixels rather than absolute depth values.

Technical Details: The loss is computed as: (1/n) * Σ(d²) - (λ/n²) * (Σd)² where d = log(pred) - log(actual), and λ controls the scale-invariance penalty.

Reference: Eigen et al., "Depth Map Prediction from a Single Image using a Multi-Scale Deep Network"

Constructors

ScaleInvariantDepthLoss(double)

Initializes a new instance of the ScaleInvariantDepthLoss class.

public ScaleInvariantDepthLoss(double lambda = 0.5)

Parameters

lambda double

The scale-invariance weight (default: 0.5). Higher values increase scale invariance.

Methods

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

Calculates the derivative (gradient) of the loss function.

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

Parameters

predicted Vector<T>

The predicted values from the model.

actual Vector<T>

The actual (target) values.

Returns

Vector<T>

A vector containing the derivatives of the loss with respect to each prediction.

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

Calculates the loss between predicted and actual values.

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

Parameters

predicted Vector<T>

The predicted values from the model.

actual Vector<T>

The actual (target) values.

Returns

T

The loss value.