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

Binary Cross Entropy Loss with autograd support. More...

#include <losses.hpp>

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

Public Member Functions

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

Binary Cross Entropy Loss with autograd support.

BCE(y_pred, y_true) = -[y_true * log(y_pred) + (1 - y_true) * log(1 - y_pred)]

Commonly used for binary classification.

Definition at line 121 of file losses.hpp.

Constructor & Destructor Documentation

◆ BCELoss()

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

Constructor.

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

Definition at line 127 of file losses.hpp.

Member Function Documentation

◆ forward()

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

Forward pass: compute binary cross entropy loss.

Parameters
predictionsPredicted probabilities (after sigmoid)
targetsBinary target values (0 or 1)
Returns
BCE loss

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

Definition at line 86 of file losses.cpp.


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