negative_log_likelihood.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_LAYER_NEGATIVE_LOG_LIKELIHOOD_HPP
13 #define MLPACK_METHODS_ANN_LAYER_NEGATIVE_LOG_LIKELIHOOD_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace ann {
19 
29 template<typename MatType = arma::mat>
31 {
32  public:
42  NegativeLogLikelihoodType(const bool reduction = true);
43 
52  double Forward(const MatType& prediction,
53  const MatType& target);
54 
67  void Backward(const MatType& prediction,
68  const MatType& target,
69  MatType& loss);
70 
73  bool Reduction() const { return reduction; }
75  bool& Reduction() { return reduction; }
76 
80  template<typename Archive>
81  void serialize(Archive& /* ar */, const uint32_t /* version */);
82 
83  private:
85  bool reduction;
86 }; // class NegativeLogLikelihoodType
87 
88 // Default typedef for typical `arma::mat` usage.
90 
91 } // namespace ann
92 } // namespace mlpack
93 
94 // Include implementation.
95 #include "negative_log_likelihood_impl.hpp"
96 
97 #endif
bool & Reduction()
Modify the type of reduction used.
NegativeLogLikelihoodType(const bool reduction=true)
Create the NegativeLogLikelihoodTypeLayer object.
void Backward(const MatType &prediction, const MatType &target, MatType &loss)
Ordinary feed backward pass of a neural network.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes, Armadillo, cereal, and a few basic mlpa...
double Forward(const MatType &prediction, const MatType &target)
Computes the Negative log likelihood.
Implementation of the negative log likelihood layer.
void serialize(Archive &, const uint32_t)
Serialize the layer.
NegativeLogLikelihoodType< arma::mat > NegativeLogLikelihood
bool Reduction() const
Get the reduction type, represented as boolean (false &#39;mean&#39; reduction, true &#39;sum&#39; reduction)...