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

Binary Cross Entropy with Logits Loss. More...

#include <losses.hpp>

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

Public Member Functions

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

Binary Cross Entropy with Logits Loss.

Combines sigmoid and BCE for numerical stability. More stable than applying sigmoid then BCE separately.

Definition at line 148 of file losses.hpp.

Constructor & Destructor Documentation

◆ BCEWithLogitsLoss()

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

Constructor.

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

Definition at line 154 of file losses.hpp.

Member Function Documentation

◆ forward()

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

Forward pass: compute BCE loss from logits.

Parameters
predictionsRaw logits (before sigmoid)
targetsBinary target values (0 or 1)
Returns
BCE loss

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

Definition at line 121 of file losses.cpp.


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