NegativeLogLikelihoodType< MatType > Class Template Reference

Implementation of the negative log likelihood layer. More...

Public Member Functions

 NegativeLogLikelihoodType (const bool reduction=true)
 Create the NegativeLogLikelihoodTypeLayer object. More...

 
void Backward (const MatType &prediction, const MatType &target, MatType &loss)
 Ordinary feed backward pass of a neural network. More...

 
double Forward (const MatType &prediction, const MatType &target)
 Computes the Negative log likelihood. More...

 
bool Reduction () const
 Get the reduction type, represented as boolean (false 'mean' reduction, true 'sum' reduction). More...

 
bool & Reduction ()
 Modify the type of reduction used. More...

 
template
<
typename
Archive
>
void serialize (Archive &, const uint32_t)
 Serialize the layer. More...

 

Detailed Description


template
<
typename
MatType
=
arma::mat
>

class mlpack::ann::NegativeLogLikelihoodType< MatType >

Implementation of the negative log likelihood layer.

The negative log likelihood layer expects that the input contains log-probabilities for each class. The layer also expects a class index in the range [0, numClasses - 1] number of classes, as target when calling the Forward function.

Template Parameters
MatTypeMatrix representation to accept as input and use for computation.

Definition at line 30 of file negative_log_likelihood.hpp.

Constructor & Destructor Documentation

◆ NegativeLogLikelihoodType()

NegativeLogLikelihoodType ( const bool  reduction = true)

Create the NegativeLogLikelihoodTypeLayer object.

Parameters
reductionSpecifies the reduction to apply to the output. If false, 'mean' reduction is used, where sum of the output will be divided by the number of elements in the output. If true, 'sum' reduction is used and the output will be summed. It is set to true by default.

Member Function Documentation

◆ Backward()

void Backward ( const MatType &  prediction,
const MatType &  target,
MatType &  loss 
)

Ordinary feed backward pass of a neural network.

The negative log likelihood layer expects that the input contains log-probabilities for each class. The layer also 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.

◆ Forward()

double Forward ( const MatType &  prediction,
const MatType &  target 
)

Computes the Negative log likelihood.

Parameters
ipredictionPredictions 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.

◆ Reduction() [1/2]

bool Reduction ( ) const
inline

Get the reduction type, represented as boolean (false 'mean' reduction, true 'sum' reduction).

Definition at line 73 of file negative_log_likelihood.hpp.

◆ Reduction() [2/2]

bool& Reduction ( )
inline

Modify the type of reduction used.

Definition at line 75 of file negative_log_likelihood.hpp.

References NegativeLogLikelihoodType< MatType >::serialize().

◆ serialize()

void serialize ( Archive &  ,
const uint32_t   
)

Serialize the layer.

Referenced by NegativeLogLikelihoodType< MatType >::Reduction().


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