PoissonNLLLoss< InputDataType, OutputDataType > Class Template Reference

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

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
void Backward (const InputType &input, const TargetType &target, OutputType &output)
 Ordinary feed backward pass of a neural network. More...

 
InputDataType::elem_type Eps () const
 Get the value of eps. More...

 
InputDataType::elem_type & Eps ()
 Modify the value of eps. More...

 
template
InputDataType::elem_type Forward (const InputType &input, const TargetType &target)
 Computes the Poisson negative log likelihood Loss. More...

 
bool Full () const
 Get the value of full. More...

 
bool & Full ()
 Modify the value of full. More...

 
InputDataType & InputParameter () const
 Get the input parameter. More...

 
InputDataType & InputParameter ()
 Modify the input parameter. More...

 
bool LogInput () const
 Get the value of logInput. More...

 
bool & LogInput ()
 Modify the value of logInput. More...

 
bool Mean () const
 Get the value of mean. More...

 
bool & Mean ()
 Modify the value of mean. More...

 
OutputDataType & OutputParameter () const
 Get the output parameter. More...

 
OutputDataType & OutputParameter ()
 Modify the output parameter. More...

 
template
void serialize (Archive &ar, const unsigned int)
 Serialize the layer. More...

 

Detailed Description


template
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).

Definition at line 36 of file poisson_nll_loss.hpp.

Constructor & Destructor Documentation

◆ PoissonNLLLoss()

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()

void Backward ( const InputType &  input,
const TargetType &  target,
OutputType &  output 
)

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
inputThe propagated input activation.
targetThe target vector, that contains the class index in the range between 1 and the number of classes.
outputThe calculated error.

◆ Eps() [1/2]

InputDataType::elem_type Eps ( ) const
inline

Get the value of eps.

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

Definition at line 108 of file poisson_nll_loss.hpp.

◆ Eps() [2/2]

InputDataType::elem_type& Eps ( )
inline

Modify the value of eps.

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

Definition at line 111 of file poisson_nll_loss.hpp.

◆ Forward()

InputDataType::elem_type Forward ( const InputType &  input,
const TargetType &  target 
)

Computes the Poisson negative log likelihood Loss.

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

◆ Full() [1/2]

bool Full ( ) const
inline

Get the value of full.

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

Definition at line 101 of file poisson_nll_loss.hpp.

◆ Full() [2/2]

bool& Full ( )
inline

Modify the value of full.

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

Definition at line 104 of file poisson_nll_loss.hpp.

◆ InputParameter() [1/2]

InputDataType& InputParameter ( ) const
inline

Get the input parameter.

Definition at line 83 of file poisson_nll_loss.hpp.

◆ InputParameter() [2/2]

InputDataType& InputParameter ( )
inline

Modify the input parameter.

Definition at line 85 of file poisson_nll_loss.hpp.

◆ LogInput() [1/2]

bool LogInput ( ) const
inline

Get the value of logInput.

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

Definition at line 94 of file poisson_nll_loss.hpp.

◆ LogInput() [2/2]

bool& LogInput ( )
inline

Modify the value of logInput.

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

Definition at line 97 of file poisson_nll_loss.hpp.

◆ Mean() [1/2]

bool 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.

Definition at line 115 of file poisson_nll_loss.hpp.

◆ Mean() [2/2]

bool& Mean ( )
inline

Modify the value of mean.

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

Definition at line 118 of file poisson_nll_loss.hpp.

References Log::Fatal, and PoissonNLLLoss< InputDataType, OutputDataType >::serialize().

◆ OutputParameter() [1/2]

OutputDataType& OutputParameter ( ) const
inline

Get the output parameter.

Definition at line 88 of file poisson_nll_loss.hpp.

◆ OutputParameter() [2/2]

OutputDataType& OutputParameter ( )
inline

Modify the output parameter.

Definition at line 90 of file poisson_nll_loss.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const unsigned  int 
)

Serialize the layer.

Referenced by PoissonNLLLoss< InputDataType, OutputDataType >::Mean().


The documentation for this class was generated from the following file:
  • /home/jenkins-mlpack/mlpack.org/_src/mlpack-3.4.2/src/mlpack/methods/ann/loss_functions/poisson_nll_loss.hpp