Deep Learning Algorithm Implementations 1.0.0
C++ implementations of fundamental deep learning algorithms
Loading...
Searching...
No Matches
dl::loss::HuberLoss< T > Class Template Reference

Huber Loss with autograd support. More...

#include <losses.hpp>

Inheritance diagram for dl::loss::HuberLoss< T >:
Collaboration diagram for dl::loss::HuberLoss< T >:

Public Member Functions

 HuberLoss (T delta=1.0, const std::string &reduction="mean")
 Constructor.
 
Variable< T > forward (const Variable< T > &predictions, const Variable< T > &targets) override
 Forward pass: compute Huber loss.
 
- Public Member Functions inherited from dl::loss::AutogradLoss< T >
virtual ~AutogradLoss ()=default
 
Variable< T > operator() (const Variable< T > &predictions, const Variable< T > &targets)
 Convenience operator for computing loss.
 

Detailed Description

template<typename T>
class dl::loss::HuberLoss< T >

Huber Loss with autograd support.

Combines MSE and MAE for robustness to outliers.

Huber(y_pred, y_true) = { 0.5 * (y_pred - y_true)² if |y_pred - y_true| <= delta delta * |y_pred - y_true| - 0.5 * delta² otherwise }

Definition at line 207 of file losses.hpp.

Constructor & Destructor Documentation

◆ HuberLoss()

template<typename T >
dl::loss::HuberLoss< T >::HuberLoss ( delta = 1.0,
const std::string &  reduction = "mean" 
)
inlineexplicit

Constructor.

Parameters
deltaThreshold for switching between MSE and MAE
reductionType of reduction ('mean', 'sum', 'none')

Definition at line 214 of file losses.hpp.

Member Function Documentation

◆ forward()

template<typename T >
Variable< T > dl::loss::HuberLoss< T >::forward ( const Variable< T > &  predictions,
const Variable< T > &  targets 
)
overridevirtual

Forward pass: compute Huber loss.

Parameters
predictionsPredicted values
targetsTarget values
Returns
Huber loss

Implements dl::loss::AutogradLoss< T >.

Definition at line 166 of file losses.cpp.


The documentation for this class was generated from the following files: