13 #ifndef MLPACK_METHODS_ANN_LAYER_ATROUS_CONVOLUTION_HPP 14 #define MLPACK_METHODS_ANN_LAYER_ATROUS_CONVOLUTION_HPP 46 typename ForwardConvolutionRule = NaiveConvolution<ValidConvolution>,
47 typename BackwardConvolutionRule = NaiveConvolution<FullConvolution>,
48 typename GradientConvolutionRule = NaiveConvolution<ValidConvolution>,
49 typename InputDataType = arma::mat,
50 typename OutputDataType = arma::mat
79 const size_t kernelWidth,
80 const size_t kernelHeight,
81 const size_t strideWidth = 1,
82 const size_t strideHeight = 1,
83 const size_t padW = 0,
84 const size_t padH = 0,
85 const size_t inputWidth = 0,
86 const size_t inputHeight = 0,
87 const size_t dilationWidth = 1,
88 const size_t dilationHeight = 1,
89 const std::string& paddingType =
"None");
115 const size_t outSize,
116 const size_t kernelWidth,
117 const size_t kernelHeight,
118 const size_t strideWidth,
119 const size_t strideHeight,
120 const std::tuple<size_t, size_t>& padW,
121 const std::tuple<size_t, size_t>& padH,
122 const size_t inputWidth = 0,
123 const size_t inputHeight = 0,
124 const size_t dilationWidth = 1,
125 const size_t dilationHeight = 1,
126 const std::string& paddingType =
"None");
140 template<
typename eT>
141 void Forward(
const arma::Mat<eT>& input, arma::Mat<eT>& output);
152 template<
typename eT>
153 void Backward(
const arma::Mat<eT>& ,
154 const arma::Mat<eT>& gy,
164 template<
typename eT>
165 void Gradient(
const arma::Mat<eT>& ,
166 const arma::Mat<eT>& error,
167 arma::Mat<eT>& gradient);
180 const OutputDataType&
Delta()
const {
return delta; }
182 OutputDataType&
Delta() {
return delta; }
185 const OutputDataType&
Gradient()
const {
return gradient; }
251 arma::mat&
Bias() {
return bias; }
256 template<
typename Archive>
257 void serialize(Archive& ar,
const unsigned int );
271 size_t ConvOutSize(
const size_t size,
274 const size_t pSideOne,
275 const size_t pSideTwo,
278 return std::floor(size + pSideOne + pSideTwo - d * (k - 1) - 1) / s + 1;
284 void InitializeSamePadding(
size_t& padWLeft,
287 size_t& padHTop)
const;
295 template<
typename eT>
296 void Rotate180(
const arma::Cube<eT>& input, arma::Cube<eT>& output)
298 output = arma::Cube<eT>(input.n_rows, input.n_cols, input.n_slices);
301 for (
size_t s = 0; s < output.n_slices; s++)
302 output.slice(s) = arma::fliplr(arma::flipud(input.slice(s)));
311 template<
typename eT>
312 void Rotate180(
const arma::Mat<eT>& input, arma::Mat<eT>& output)
315 output = arma::fliplr(arma::flipud(input));
340 OutputDataType weights;
361 size_t dilationWidth;
364 size_t dilationHeight;
367 arma::cube outputTemp;
370 arma::cube inputPaddedTemp;
376 arma::cube gradientTemp;
382 OutputDataType delta;
385 OutputDataType gradient;
388 OutputDataType outputParameter;
396 namespace serialization {
399 typename ForwardConvolutionRule,
400 typename BackwardConvolutionRule,
401 typename GradientConvolutionRule,
402 typename InputDataType,
403 typename OutputDataType
406 mlpack::ann::AtrousConvolution<ForwardConvolutionRule,
407 BackwardConvolutionRule, GradientConvolutionRule, InputDataType,
410 BOOST_STATIC_CONSTANT(
int, value = 2);
417 #include "atrous_convolution_impl.hpp" ann::Padding & Padding()
Modify the internal Padding layer.
size_t & DilationHeight()
Modify the dilation rate on the Y axis.
size_t & StrideWidth()
Modify the stride width.
Set the serialization version of the adaboost class.
arma::mat & Bias()
Modify the bias weights of the layer.
Linear algebra utility functions, generally performed on matrices or vectors.
Implementation of the Padding module class.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Delta()
Modify the delta.
size_t & InputHeight()
Modify the input height.
const OutputDataType & Delta() const
Get the delta.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t KernelWidth() const
Get the kernel width.
OutputDataType & OutputParameter()
Modify the output parameter.
OutputDataType & Parameters()
Modify the parameters.
size_t DilationWidth() const
Get the dilation rate on the X axis.
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...
AtrousConvolution()
Create the AtrousConvolution object.
const size_t & InputHeight() const
Get the input height.
const OutputDataType & OutputParameter() const
Get the output parameter.
size_t KernelHeight() const
Get the kernel height.
const size_t & OutputSize() const
Get the output size.
size_t & InputWidth()
Modify input the width.
const OutputDataType & Parameters() const
Get the parameters.
size_t & StrideHeight()
Modify the stride height.
const ann::Padding & Padding() const
Get the internal Padding layer.
size_t & KernelWidth()
Modify the kernel width.
size_t StrideHeight() const
Get the stride height.
const size_t & OutputWidth() const
Get the output width.
size_t & DilationWidth()
Modify the dilation rate on the X axis.
const size_t & InputSize() const
Get the input size.
size_t StrideWidth() const
Get the stride width.
size_t & KernelHeight()
Modify the kernel height.
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...
size_t DilationHeight() const
Get the dilation rate on the Y axis.
OutputDataType & Gradient()
Modify the gradient.
const OutputDataType & Gradient() const
Get the gradient.
const size_t & InputWidth() const
Get the input width.
size_t & OutputWidth()
Modify the output width.
const size_t & OutputHeight() const
Get the output height.
size_t & OutputHeight()
Modify the output height.
Implementation of the Atrous Convolution class.