softmax.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_ANN_LAYER_SOFTMAX_HPP
15 #define MLPACK_METHODS_ANN_LAYER_SOFTMAX_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 namespace mlpack {
20 namespace ann {
21 
34 template <
35  typename InputDataType = arma::mat,
36  typename OutputDataType = arma::mat
37 >
38 class Softmax
39 {
40  public:
44  Softmax();
45 
53  template<typename InputType, typename OutputType>
54  void Forward(const InputType& input, OutputType& output);
55 
65  template<typename eT>
66  void Backward(const arma::Mat<eT>& input,
67  const arma::Mat<eT>& gy,
68  arma::Mat<eT>& g);
69 
71  OutputDataType& OutputParameter() const { return outputParameter; }
73  OutputDataType& OutputParameter() { return outputParameter; }
74 
76  InputDataType& Delta() const { return delta; }
78  InputDataType& Delta() { return delta; }
79 
83  template<typename Archive>
84  void serialize(Archive& /* ar */, const unsigned int /* version */);
85 
86  private:
88  OutputDataType delta;
89 
91  OutputDataType outputParameter;
92 }; // class Softmax
93 
94 } // namespace ann
95 } // namespace mlpack
96 
97 // Include implementation.
98 #include "softmax_impl.hpp"
99 
100 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_po.hpp:21
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: softmax.hpp:73
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
The core includes that mlpack expects; standard C++ includes and Armadillo.
InputDataType & Delta() const
Get the delta.
Definition: softmax.hpp:76
Implementation of the Softmax layer.
Definition: softmax.hpp:38
Softmax()
Create the Softmax object.
InputDataType & Delta()
Modify the delta.
Definition: softmax.hpp:78
void serialize(Archive &, const unsigned int)
Serialize the layer.
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: softmax.hpp:71
void Backward(const arma::Mat< eT > &input, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
Ordinary feed backward pass of a neural network, calculating the function f(x) by propagating x backw...