mlpack
Public Member Functions | List of all members
mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType > Class Template Reference

Implementation of the Poisson negative log likelihood loss. More...

#include <poisson_nll_loss.hpp>

Public Member Functions

 PoissonNLLLoss (const bool logInput=true, const bool full=false, const typename InputDataType::elem_type eps=1e-08, const bool mean=true)
 Create the PoissonNLLLoss object. More...
 
template<typename PredictionType , typename TargetType >
InputDataType::elem_type Forward (const PredictionType &prediction, const TargetType &target)
 Computes the Poisson negative log likelihood Loss. More...
 
template<typename PredictionType , typename TargetType , typename LossType >
void Backward (const PredictionType &prediction, const TargetType &target, LossType &loss)
 Ordinary feed backward pass of a neural network. More...
 
InputDataType & InputParameter () const
 Get the input parameter.
 
InputDataType & InputParameter ()
 Modify the input parameter.
 
OutputDataType & OutputParameter () const
 Get the output parameter.
 
OutputDataType & OutputParameter ()
 Modify the output parameter.
 
bool LogInput () const
 Get the value of logInput. More...
 
bool & LogInput ()
 Modify the value of logInput. More...
 
bool Full () const
 Get the value of full. More...
 
bool & Full ()
 Modify the value of full. More...
 
InputDataType::elem_type Eps () const
 Get the value of eps. More...
 
InputDataType::elem_type & Eps ()
 Modify the value of eps. More...
 
bool Mean () const
 Get the value of mean. More...
 
bool & Mean ()
 Modify the value of mean. More...
 
template<typename Archive >
void serialize (Archive &ar, const uint32_t)
 Serialize the layer.
 

Detailed Description

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
class mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >

Implementation of the Poisson negative log likelihood loss.

This loss function expects input for each class. It also expects a class index, in the range between 1 and the number of classes, as target when calling the Forward function.

Template Parameters
InputDataTypeType of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube).
OutputDataTypeType of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube).

Constructor & Destructor Documentation

◆ PoissonNLLLoss()

template<typename InputDataType , typename OutputDataType >
mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::PoissonNLLLoss ( const bool  logInput = true,
const bool  full = false,
const typename InputDataType::elem_type  eps = 1e-08,
const bool  mean = true 
)

Create the PoissonNLLLoss object.

Parameters
logInputIf true the loss is computed as \( \exp(input) - target \cdot input \), if false then the loss is \( input - target \cdot \log(input + eps) \).
fullBoolean value that determines whether to include Stirling's approximation term.
epsA small value to prevent 0 in denominators and logarithms.
meanWhen true, mean loss is computed otherwise total loss.

Member Function Documentation

◆ Backward()

template<typename InputDataType , typename OutputDataType >
template<typename PredictionType , typename TargetType , typename LossType >
void mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::Backward ( const PredictionType &  prediction,
const TargetType &  target,
LossType &  loss 
)

Ordinary feed backward pass of a neural network.

The Poisson Negative Log Likelihood loss function expects the input for each class. It expects a class index, in the range between 1 and the number of classes, as target when calling the Forward function.

Parameters
predictionPredictions used for evaluating the specified loss function.
targetThe target vector, that contains the class index in the range between 1 and the number of classes.
lossThe calculated error.

◆ Eps() [1/2]

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
InputDataType::elem_type mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::Eps ( ) const
inline

Get the value of eps.

eps is a small value required to prevent 0 in logarithms and denominators.

◆ Eps() [2/2]

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
InputDataType::elem_type& mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::Eps ( )
inline

Modify the value of eps.

eps is a small value required to prevent 0 in logarithms and denominators.

◆ Forward()

template<typename InputDataType , typename OutputDataType >
template<typename PredictionType , typename TargetType >
InputDataType::elem_type mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::Forward ( const PredictionType &  prediction,
const TargetType &  target 
)

Computes the Poisson negative log likelihood Loss.

Parameters
predictionPredictions used for evaluating the specified loss function.
targetThe target vector, that contains the class index in the range between 1 and the number of classes.

◆ Full() [1/2]

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
bool mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::Full ( ) const
inline

Get the value of full.

full is a boolean value that determines whether to include Stirling's approximation term.

◆ Full() [2/2]

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
bool& mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::Full ( )
inline

Modify the value of full.

full is a boolean value that determines whether to include Stirling's approximation term.

◆ LogInput() [1/2]

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
bool mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::LogInput ( ) const
inline

Get the value of logInput.

logInput is a boolean value that tells if logits are given as input.

◆ LogInput() [2/2]

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
bool& mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::LogInput ( )
inline

Modify the value of logInput.

logInput is a boolean value that tells if logits are given as input.

◆ Mean() [1/2]

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
bool mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::Mean ( ) const
inline

Get the value of mean.

It's a boolean value that tells if mean of the total loss has to be taken.

◆ Mean() [2/2]

template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
bool& mlpack::ann::PoissonNLLLoss< InputDataType, OutputDataType >::Mean ( )
inline

Modify the value of mean.

It's a boolean value that tells if mean of the total loss has to be taken.


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