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

Hinge Loss with autograd support. More...

#include <losses.hpp>

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

Public Member Functions

 HingeLoss (const std::string &reduction="mean")
 Constructor.
 
Variable< T > forward (const Variable< T > &predictions, const Variable< T > &targets) override
 Forward pass: compute hinge 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::HingeLoss< T >

Hinge Loss with autograd support.

Hinge(y_pred, y_true) = max(0, 1 - y_true * y_pred)

Commonly used for SVM and margin-based classification.

Definition at line 176 of file losses.hpp.

Constructor & Destructor Documentation

◆ HingeLoss()

template<typename T >
dl::loss::HingeLoss< T >::HingeLoss ( const std::string &  reduction = "mean")
inlineexplicit

Constructor.

Parameters
reductionType of reduction ('mean', 'sum', 'none')

Definition at line 182 of file losses.hpp.

Member Function Documentation

◆ forward()

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

Forward pass: compute hinge loss.

Parameters
predictionsPredicted values
targetsTarget values (-1 or +1)
Returns
Hinge loss

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

Definition at line 137 of file losses.cpp.


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