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
75 const size_t padW = 0,
76 const size_t padH = 0,
77 const size_t inputWidth = 0,
78 const size_t inputHeight = 0,
79 const std::string paddingType =
"None");
102 const size_t outSize,
107 const std::tuple<size_t, size_t> padW,
108 const std::tuple<size_t, size_t> padH,
109 const size_t inputWidth = 0,
110 const size_t inputHeight = 0,
111 const std::string paddingType =
"None");
125 template<
typename eT>
126 void Forward(
const arma::Mat<eT>&& input, arma::Mat<eT>&& output);
137 template<
typename eT>
138 void Backward(
const arma::Mat<eT>&& ,
149 template<
typename eT>
150 void Gradient(
const arma::Mat<eT>&& ,
151 arma::Mat<eT>&& error,
152 arma::Mat<eT>&& gradient);
170 OutputDataType
const&
Delta()
const {
return delta; }
172 OutputDataType&
Delta() {
return delta; }
175 OutputDataType
const&
Gradient()
const {
return gradient; }
200 arma::mat&
Bias() {
return bias; }
205 template<
typename Archive>
206 void serialize(Archive& ar,
const unsigned int );
219 size_t ConvOutSize(
const size_t size,
222 const size_t pSideOne,
223 const size_t pSideTwo)
225 return std::floor(size + pSideOne + pSideTwo - k) / s + 1;
231 void InitializeSamePadding();
239 template<
typename eT>
240 void Rotate180(
const arma::Cube<eT>& input, arma::Cube<eT>& output)
242 output = arma::Cube<eT>(input.n_rows, input.n_cols, input.n_slices);
245 for (
size_t s = 0; s < output.n_slices; s++)
246 output.slice(s) = arma::fliplr(arma::flipud(input.slice(s)));
255 template<
typename eT>
256 void Rotate180(
const arma::Mat<eT>& input, arma::Mat<eT>& output)
259 output = arma::fliplr(arma::flipud(input));
296 OutputDataType weights;
317 arma::cube outputTemp;
320 arma::cube inputTemp;
323 arma::cube inputPaddedTemp;
329 arma::cube gradientTemp;
335 OutputDataType delta;
338 OutputDataType gradient;
341 InputDataType inputParameter;
344 OutputDataType outputParameter;
352 namespace serialization {
355 typename ForwardConvolutionRule,
356 typename BackwardConvolutionRule,
357 typename GradientConvolutionRule,
358 typename InputDataType,
359 typename OutputDataType
362 mlpack::ann::Convolution<ForwardConvolutionRule, BackwardConvolutionRule,
363 GradientConvolutionRule, InputDataType, OutputDataType> >
365 BOOST_STATIC_CONSTANT(
int, value = 1);
372 #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.
Set the serialization version of the adaboost class.
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.