mlpack  master
log_softmax.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_LAYER_LOG_SOFTMAX_HPP
13 #define MLPACK_METHODS_ANN_LAYER_LOG_SOFTMAX_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace ann {
19 
32 template <
33  typename InputDataType = arma::mat,
34  typename OutputDataType = arma::mat
35 >
37 {
38  public:
42  LogSoftMax();
43 
51  template<typename InputType, typename OutputType>
52  void Forward(const InputType&& input, OutputType&& output);
53 
63  template<typename eT>
64  void Backward(const arma::Mat<eT>&& input,
65  arma::Mat<eT>&& gy,
66  arma::Mat<eT>&& g);
67 
69  InputDataType& InputParameter() const { return inputParameter; }
71  InputDataType& InputParameter() { return inputParameter; }
72 
74  OutputDataType& OutputParameter() const { return outputParameter; }
76  OutputDataType& OutputParameter() { return outputParameter; }
77 
79  InputDataType& Delta() const { return delta; }
81  InputDataType& Delta() { return delta; }
82 
86  template<typename Archive>
87  void Serialize(Archive& /* ar */, const unsigned int /* version */);
88 
89  private:
91  OutputDataType delta;
92 
94  InputDataType inputParameter;
95 
97  OutputDataType outputParameter;
98 }; // class LogSoftmax
99 
100 } // namespace ann
101 } // namespace mlpack
102 
103 // Include implementation.
104 #include "log_softmax_impl.hpp"
105 
106 #endif
OutputDataType delta
Locally-stored delta object.
Definition: log_softmax.hpp:91
Implementation of the log softmax layer.
Definition: log_softmax.hpp:36
InputDataType inputParameter
Locally-stored input parameter object.
Definition: log_softmax.hpp:94
void Serialize(Archive &, const unsigned int)
Serialize the layer.
InputDataType & InputParameter() const
Get the input parameter.
Definition: log_softmax.hpp:69
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
OutputDataType outputParameter
Locally-stored output parameter object.
Definition: log_softmax.hpp:97
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.
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: log_softmax.hpp:74
InputDataType & Delta()
Modify the delta.
Definition: log_softmax.hpp:81
InputDataType & InputParameter()
Modify the input parameter.
Definition: log_softmax.hpp:71
void Backward(const arma::Mat< eT > &&input, 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...
InputDataType & Delta() const
Get the delta.
Definition: log_softmax.hpp:79
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: log_softmax.hpp:76
LogSoftMax()
Create the LogSoftmax object.