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

Mean Squared Error Loss with autograd support. More...

#include <losses.hpp>

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

Public Member Functions

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

Mean Squared Error Loss with autograd support.

MSE(y_pred, y_true) = (1/n) * sum((y_pred - y_true)²)

Commonly used for regression tasks.

Definition at line 55 of file losses.hpp.

Constructor & Destructor Documentation

◆ MSELoss()

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

Constructor.

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

Definition at line 61 of file losses.hpp.

Member Function Documentation

◆ forward()

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

Forward pass: compute MSE loss.

Parameters
predictionsPredicted values
targetsTarget values
Returns
MSE loss

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

Definition at line 12 of file losses.cpp.


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