padding.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_LAYER_PADDING_HPP
13 #define MLPACK_METHODS_ANN_LAYER_PADDING_HPP
14 
15 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace ann {
20 
30 template <
31  typename InputDataType = arma::mat,
32  typename OutputDataType = arma::mat
33 >
34 class Padding
35 {
36  public:
45  Padding(const size_t padWLeft = 0,
46  const size_t padWRight = 0,
47  const size_t padHTop = 0,
48  const size_t padHBottom = 0);
49 
57  template<typename eT>
58  void Forward(const arma::Mat<eT>&& input, arma::Mat<eT>&& output);
59 
69  template<typename eT>
70  void Backward(const arma::Mat<eT>&& /* input */,
71  const arma::Mat<eT>&& gy,
72  arma::Mat<eT>&& g);
73 
75  OutputDataType const& OutputParameter() const { return outputParameter; }
77  OutputDataType& OutputParameter() { return outputParameter; }
78 
80  OutputDataType const& Delta() const { return delta; }
82  OutputDataType& Delta() { return delta; }
83 
87  template<typename Archive>
88  void serialize(Archive& ar, const unsigned int /* version */);
89 
90  private:
92  size_t padWLeft;
93 
95  size_t padWRight;
96 
98  size_t padHTop;
99 
101  size_t padHBottom;
102 
104  size_t nRows, nCols;
105 
107  OutputDataType delta;
108 
110  OutputDataType outputParameter;
111 }; // class Padding
112 
113 } // namespace ann
114 } // namespace mlpack
115 
116 // Include implementation.
117 #include "padding_impl.hpp"
118 
119 #endif
Padding(const size_t padWLeft=0, const size_t padWRight=0, const size_t padHTop=0, const size_t padHBottom=0)
Create the Padding object using the specified number of output units.
void Forward(const arma::Mat< eT > &&input, arma::Mat< eT > &&output)
Ordinary feed forward pass of a neural network, evaluating the function f(x) by propagating the activ...
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: padding.hpp:75
OutputDataType const & Delta() const
Get the delta.
Definition: padding.hpp:80
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: padding.hpp:77
void Backward(const arma::Mat< eT > &&, 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...
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Delta()
Modify the delta.
Definition: padding.hpp:82