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  size_t WeightSize() const { return 0; }
77 
79  InputDataType& Delta() const { return delta; }
81  InputDataType& Delta() { return delta; }
82 
86  template<typename Archive>
87  void serialize(Archive& /* ar */, const uint32_t /* version */);
88 
89  private:
91  OutputDataType delta;
92 
94  OutputDataType outputParameter;
95 }; // class Softmax
96 
97 } // namespace ann
98 } // namespace mlpack
99 
100 // Include implementation.
101 #include "softmax_impl.hpp"
102 
103 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
size_t WeightSize() const
Get the size of the weights.
Definition: softmax.hpp:76
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:79
Implementation of the Softmax layer.
Definition: softmax.hpp:38
Softmax()
Create the Softmax object.
InputDataType & Delta()
Modify the delta.
Definition: softmax.hpp:81
void serialize(Archive &, const uint32_t)
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...