cross_entropy_error.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_LAYER_CROSS_ENTROPY_ERROR_HPP
13 #define MLPACK_METHODS_ANN_LAYER_CROSS_ENTROPY_ERROR_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace ann {
19 
30 template <
31  typename InputDataType = arma::mat,
32  typename OutputDataType = arma::mat
33 >
35 {
36  public:
43  CrossEntropyError(double eps = 1e-10);
44 
45  /*
46  * Computes the cross-entropy function.
47  *
48  * @param input Input data used for evaluating the specified function.
49  * @param output Resulting output activation.
50  */
51  template<typename InputType, typename TargetType>
52  double Forward(const InputType&& input, const TargetType&& target);
60  template<typename InputType, typename TargetType, typename OutputType>
61  void Backward(const InputType&& input,
62  const TargetType&& target,
63  OutputType&& output);
64 
66  InputDataType& InputParameter() const { return inputParameter; }
68  InputDataType& InputParameter() { return inputParameter; }
69 
71  OutputDataType& OutputParameter() const { return outputParameter; }
73  OutputDataType& OutputParameter() { return outputParameter; }
74 
76  OutputDataType& Delta() const { return delta; }
78  OutputDataType& Delta() { return delta; }
79 
81  double Eps() const { return eps; }
83  double& Eps() { return eps; }
84 
88  template<typename Archive>
89  void serialize(Archive& ar, const unsigned int /* version */);
90 
91  private:
93  OutputDataType delta;
94 
96  InputDataType inputParameter;
97 
99  OutputDataType outputParameter;
100 
102  double eps;
103 }; // class CrossEntropyError
104 
105 } // namespace ann
106 } // namespace mlpack
107 
108 // Include implementation.
109 #include "cross_entropy_error_impl.hpp"
110 
111 #endif
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
void Backward(const InputType &&input, const TargetType &&target, OutputType &&output)
Ordinary feed backward pass of a neural network.
OutputDataType & Delta()
Modify the delta.
InputDataType & InputParameter() const
Get the input parameter.
double Eps() const
Get the epsilon.
double Forward(const InputType &&input, const TargetType &&target)
CrossEntropyError(double eps=1e-10)
Create the CrossEntropyError object.
OutputDataType & OutputParameter() const
Get the output parameter.
OutputDataType & Delta() const
Get the delta.
The cross-entropy performance function measures the network&#39;s performance according to the cross-entr...
double & Eps()
Modify the epsilon.
InputDataType & InputParameter()
Modify the input parameter.
OutputDataType & OutputParameter()
Modify the output parameter.