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... | |
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.
MatType | Matrix representation to accept as input and use for computation. |
Definition at line 30 of file negative_log_likelihood.hpp.
NegativeLogLikelihoodType | ( | const bool | reduction = true | ) |
Create the NegativeLogLikelihoodTypeLayer object.
reduction | Specifies 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. |
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.
prediction | Predictions used for evaluating the specified loss function. |
target | The target vector, that contains the class index in the range between 1 and the number of classes. |
loss | The calculated error. |
double Forward | ( | const MatType & | prediction, |
const MatType & | target | ||
) |
Computes the Negative log likelihood.
iprediction | Predictions used for evaluating the specified loss function. |
target | The target vector, that contains the class index in the range between 1 and the number of classes. |
|
inline |
Get the reduction type, represented as boolean (false 'mean' reduction, true 'sum' reduction).
Definition at line 73 of file negative_log_likelihood.hpp.
|
inline |
Modify the type of reduction used.
Definition at line 75 of file negative_log_likelihood.hpp.
References NegativeLogLikelihoodType< MatType >::serialize().
void serialize | ( | Archive & | , |
const uint32_t | |||
) |
Serialize the layer.
Referenced by NegativeLogLikelihoodType< MatType >::Reduction().