12 #ifndef MLPACK_METHODS_ANN_LAYER_CONVOLUTION_HPP 13 #define MLPACK_METHODS_ANN_LAYER_CONVOLUTION_HPP 41 typename ForwardConvolutionRule = NaiveConvolution<ValidConvolution>,
42 typename BackwardConvolutionRule = NaiveConvolution<FullConvolution>,
43 typename GradientConvolutionRule = NaiveConvolution<ValidConvolution>,
44 typename InputDataType = arma::mat,
45 typename OutputDataType = arma::mat
74 const size_t padW = 0,
75 const size_t padH = 0,
76 const size_t inputWidth = 0,
77 const size_t inputHeight = 0);
92 void Forward(
const arma::Mat<eT>&& input, arma::Mat<eT>&& output);
103 template<
typename eT>
104 void Backward(
const arma::Mat<eT>&& ,
115 template<
typename eT>
116 void Gradient(
const arma::Mat<eT>&& ,
117 arma::Mat<eT>&& error,
118 arma::Mat<eT>&& gradient);
136 OutputDataType
const&
Delta()
const {
return delta; }
138 OutputDataType&
Delta() {
return delta; }
141 OutputDataType
const&
Gradient()
const {
return gradient; }
166 arma::mat&
Bias() {
return bias; }
171 template<
typename Archive>
172 void serialize(Archive& ar,
const unsigned int );
184 size_t ConvOutSize(
const size_t size,
189 return std::floor(size + p * 2 - k) / s + 1;
198 template<
typename eT>
199 void Rotate180(
const arma::Cube<eT>& input, arma::Cube<eT>& output)
201 output = arma::Cube<eT>(input.n_rows, input.n_cols, input.n_slices);
204 for (
size_t s = 0; s < output.n_slices; s++)
205 output.slice(s) = arma::fliplr(arma::flipud(input.slice(s)));
214 template<
typename eT>
215 void Rotate180(
const arma::Mat<eT>& input, arma::Mat<eT>& output)
218 output = arma::fliplr(arma::flipud(input));
249 OutputDataType weights;
270 arma::cube outputTemp;
273 arma::cube inputTemp;
276 arma::cube inputPaddedTemp;
282 arma::cube gradientTemp;
288 OutputDataType delta;
291 OutputDataType gradient;
294 InputDataType inputParameter;
297 OutputDataType outputParameter;
304 #include "convolution_impl.hpp" InputDataType const & InputParameter() const
Get the input parameter.
void Backward(const arma::Mat< eT > &&, 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 const & Parameters() const
Get the parameters.
Implementation of the Padding module class.
size_t & OutputHeight()
Modify the output height.
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType const & OutputParameter() const
Get the output parameter.
Implementation of the Convolution class.
size_t const & InputWidth() const
Get the input width.
OutputDataType & Gradient()
Modify the gradient.
InputDataType & InputParameter()
Modify the input parameter.
size_t const & InputHeight() const
Get the input height.
size_t & InputHeight()
Modify the input height.
arma::mat & Bias()
Modify the bias weights of the layer.
size_t const & OutputWidth() const
Get the output width.
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 & Delta() const
Get the delta.
size_t & InputWidth()
Modify input the width.
OutputDataType & Parameters()
Modify the parameters.
size_t const & OutputHeight() const
Get the output height.
size_t & OutputWidth()
Modify the output width.
OutputDataType & Delta()
Modify the delta.
OutputDataType & OutputParameter()
Modify the output parameter.
Convolution()
Create the Convolution object.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType const & Gradient() const
Get the gradient.