binary_cross_entropy_loss.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_LOSS_FUNCTIONS_CROSS_ENTROPY_ERROR_HPP
13 #define MLPACK_METHODS_ANN_LOSS_FUNCTIONS_CROSS_ENTROPY_ERROR_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace ann {
19 
27 template<typename MatType = arma::mat>
29 {
30  public:
43  BCELossType(const double eps = 1e-10, const bool reduction = true);
44 
52  typename MatType::elem_type Forward(const MatType& prediction,
53  const MatType& target);
54 
63  void Backward(const MatType& prediction,
64  const MatType& target,
65  MatType& loss);
66 
68  double Eps() const { return eps; }
70  double& Eps() { return eps; }
71 
74  bool Reduction() const { return reduction; }
76  bool& Reduction() { return reduction; }
77 
81  template<typename Archive>
82  void serialize(Archive& ar, const uint32_t /* version */);
83 
84  private:
86  double eps;
87 
89  bool reduction;
90 }; // class BCELossType
91 
92 // Default typedef for typical `arma::mat` usage.
94 
99 
100 template<typename MatType = arma::mat>
102 
103 } // namespace ann
104 } // namespace mlpack
105 
106 // Include implementation.
107 #include "binary_cross_entropy_loss_impl.hpp"
108 
109 #endif
bool Reduction() const
Get the reduction type, represented as boolean (false &#39;mean&#39; reduction, true &#39;sum&#39; reduction)...
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 and Armadillo.
MatType::elem_type Forward(const MatType &prediction, const MatType &target)
Computes the cross-entropy function.
The binary-cross-entropy performance function measures the Binary Cross Entropy between the target an...
double Eps() const
Get the epsilon.
BCELossType< arma::mat > BCELoss
BCELossType< arma::mat > CrossEntropyError
Alias of BCELossType.
bool & Reduction()
Modify the type of reduction used.
BCELossType(const double eps=1e-10, const bool reduction=true)
Create the BinaryCrossEntropyLoss object.
double & Eps()
Modify the epsilon.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.