mlpack 3.4.2
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
19namespace mlpack {
20namespace ann {
21
34template <
35 typename InputDataType = arma::mat,
36 typename OutputDataType = arma::mat
37>
39{
40 public:
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
Implementation of the Softmax layer.
Definition: softmax.hpp:39
void Forward(const InputType &input, OutputType &output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
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...
InputDataType & Delta()
Modify the delta.
Definition: softmax.hpp:78
void serialize(Archive &, const unsigned int)
Serialize the layer.
InputDataType & Delta() const
Get the delta.
Definition: softmax.hpp:76
Softmax()
Create the Softmax object.
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: softmax.hpp:73
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.