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>
154 const arma::Mat<eT>& gy,
164 template<
typename eT>
166 const arma::Mat<eT>& error,
167 arma::Mat<eT>& gradient);
175 arma::cube
const&
Weight()
const {
return weight; }
180 arma::mat
const&
Bias()
const {
return bias; }
182 arma::mat&
Bias() {
return bias; }
190 OutputDataType
const&
Delta()
const {
return delta; }
192 OutputDataType&
Delta() {
return delta; }
195 OutputDataType
const&
Gradient()
const {
return gradient; }
263 return (outSize * inSize * kernelWidth * kernelHeight) + outSize;
269 template<
typename Archive>
284 size_t ConvOutSize(
const size_t size,
287 const size_t pSideOne,
288 const size_t pSideTwo,
291 return std::floor(size + pSideOne + pSideTwo - d * (k - 1) - 1) / s + 1;
297 void InitializeSamePadding(
size_t& padWLeft,
300 size_t& padHTop)
const;
308 template<
typename eT>
309 void Rotate180(
const arma::Cube<eT>& input, arma::Cube<eT>& output)
311 output = arma::Cube<eT>(input.n_rows, input.n_cols, input.n_slices);
314 for (
size_t s = 0; s < output.n_slices; s++)
315 output.slice(s) = arma::fliplr(arma::flipud(input.slice(s)));
324 template<
typename eT>
325 void Rotate180(
const arma::Mat<eT>& input, arma::Mat<eT>& output)
328 output = arma::fliplr(arma::flipud(input));
353 OutputDataType weights;
374 size_t dilationWidth;
377 size_t dilationHeight;
380 arma::cube outputTemp;
383 arma::cube inputPaddedTemp;
389 arma::cube gradientTemp;
392 ann::Padding<> padding;
395 OutputDataType delta;
398 OutputDataType gradient;
401 OutputDataType outputParameter;
409namespace serialization {
412 typename ForwardConvolutionRule,
413 typename BackwardConvolutionRule,
414 typename GradientConvolutionRule,
415 typename InputDataType,
416 typename OutputDataType
419 mlpack::ann::AtrousConvolution<ForwardConvolutionRule,
420 BackwardConvolutionRule, GradientConvolutionRule, InputDataType,
430#include "atrous_convolution_impl.hpp"
Implementation of the Atrous Convolution class.
arma::cube const & Weight() const
Get the weight of the layer.
OutputDataType const & Delta() const
Get the delta.
size_t StrideHeight() const
Get the stride height.
size_t & DilationWidth()
Modify the dilation rate on the X axis.
OutputDataType const & Parameters() const
Get the parameters.
AtrousConvolution(const size_t inSize, const size_t outSize, const size_t kernelWidth, const size_t kernelHeight, const size_t strideWidth, const size_t strideHeight, const std::tuple< size_t, size_t > &padW, const std::tuple< size_t, size_t > &padH, const size_t inputWidth=0, const size_t inputHeight=0, const size_t dilationWidth=1, const size_t dilationHeight=1, const std::string &paddingType="None")
Create the AtrousConvolution object using the specified number of input maps, output maps,...
ann::Padding const & Padding() const
Get the internal Padding layer.
size_t & InputHeight()
Modify the input height.
size_t InputWidth() const
Get the input 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...
arma::cube & Weight()
Modify the weight of the layer.
OutputDataType const & OutputParameter() const
Get the output parameter.
size_t InputSize() const
Get the input size.
size_t & InputWidth()
Modify input the width.
size_t KernelWidth() const
Get the kernel width.
size_t KernelHeight() const
Get the kernel height.
size_t & StrideWidth()
Modify the stride width.
size_t WeightSize() const
Get size of the weight matrix.
arma::mat const & Bias() const
Get the bias of the layer.
size_t & KernelWidth()
Modify the kernel width.
size_t & OutputHeight()
Modify the output height.
AtrousConvolution()
Create the AtrousConvolution object.
size_t OutputHeight() const
Get the output height.
size_t OutputSize() const
Get the output size.
void Gradient(const arma::Mat< eT > &, const arma::Mat< eT > &error, arma::Mat< eT > &gradient)
size_t OutputWidth() const
Get the output width.
size_t & DilationHeight()
Modify the dilation rate on the Y axis.
OutputDataType const & Gradient() const
Get the gradient.
size_t InputHeight() const
Get the input height.
OutputDataType & Gradient()
Modify the gradient.
size_t DilationHeight() const
Get the dilation rate on the Y axis.
size_t & KernelHeight()
Modify the kernel height.
AtrousConvolution(const size_t inSize, const size_t outSize, const size_t kernelWidth, const size_t kernelHeight, const size_t strideWidth=1, const size_t strideHeight=1, const size_t padW=0, const size_t padH=0, const size_t inputWidth=0, const size_t inputHeight=0, const size_t dilationWidth=1, const size_t dilationHeight=1, const std::string &paddingType="None")
Create the AtrousConvolution object using the specified number of input maps, output maps,...
size_t StrideWidth() const
Get the stride width.
size_t & StrideHeight()
Modify the stride 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...
OutputDataType & OutputParameter()
Modify the output parameter.
size_t & OutputWidth()
Modify the output width.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Parameters()
Modify the parameters.
arma::mat & Bias()
Modify the bias of the layer.
ann::Padding & Padding()
Modify the internal Padding layer.
size_t DilationWidth() const
Get the dilation rate on the X axis.
OutputDataType & Delta()
Modify the delta.
Implementation of the Padding module class.
Set the serialization version of the adaboost class.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
BOOST_STATIC_CONSTANT(int, value=2)