mlpack 3.4.2
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
18namespace mlpack {
19namespace ann {
20
30template <
31 typename InputDataType = arma::mat,
32 typename OutputDataType = arma::mat
33>
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
85 size_t PadWLeft() const { return padWLeft; }
87 size_t& PadWLeft() { return padWLeft; }
88
90 size_t PadWRight() const { return padWRight; }
92 size_t& PadWRight() { return padWRight; }
93
95 size_t PadHTop() const { return padHTop; }
97 size_t& PadHTop() { return padHTop; }
98
100 size_t PadHBottom() const { return padHBottom; }
102 size_t& PadHBottom() { return padHBottom; }
103
107 template<typename Archive>
108 void serialize(Archive& ar, const unsigned int /* version */);
109
110 private:
112 size_t padWLeft;
113
115 size_t padWRight;
116
118 size_t padHTop;
119
121 size_t padHBottom;
122
124 size_t nRows, nCols;
125
127 OutputDataType delta;
128
130 OutputDataType outputParameter;
131}; // class Padding
132
133} // namespace ann
134} // namespace mlpack
135
136// Include implementation.
137#include "padding_impl.hpp"
138
139#endif
Implementation of the Padding module class.
Definition: padding.hpp:35
OutputDataType const & Delta() const
Get the delta.
Definition: padding.hpp:80
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.
size_t & PadHTop()
Modify the top padding width.
Definition: padding.hpp:97
size_t PadWLeft() const
Get the left padding width.
Definition: padding.hpp:85
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...
OutputDataType const & OutputParameter() const
Get the output parameter.
Definition: padding.hpp:75
size_t & PadHBottom()
Modify the bottom padding width.
Definition: padding.hpp:102
size_t PadHBottom() const
Get the bottom padding width.
Definition: padding.hpp:100
size_t PadWRight() const
Get the right padding width.
Definition: padding.hpp:90
size_t & PadWRight()
Modify the right padding width.
Definition: padding.hpp:92
size_t & PadWLeft()
Modify the left padding width.
Definition: padding.hpp:87
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...
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: padding.hpp:77
size_t PadHTop() const
Get the top padding width.
Definition: padding.hpp:95
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Delta()
Modify the delta.
Definition: padding.hpp:82
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.