13 #ifndef MLPACK_METHODS_ANN_LAYER_TRANSPOSED_CONVOLUTION_HPP 14 #define MLPACK_METHODS_ANN_LAYER_TRANSPOSED_CONVOLUTION_HPP 42 typename ForwardConvolutionRule = NaiveConvolution<ValidConvolution>,
43 typename BackwardConvolutionRule = NaiveConvolution<FullConvolution>,
44 typename GradientConvolutionRule = NaiveConvolution<ValidConvolution>,
45 typename InputDataType = arma::mat,
46 typename OutputDataType = arma::mat
48 class TransposedConvolution
75 const size_t padW = 0,
76 const size_t padH = 0,
77 const size_t inputWidth = 0,
78 const size_t inputHeight = 0);
93 void Forward(
const arma::Mat<eT>&& input, arma::Mat<eT>&& output);
104 template<
typename eT>
105 void Backward(
const arma::Mat<eT>&& ,
116 template<
typename eT>
117 void Gradient(
const arma::Mat<eT>&& ,
118 arma::Mat<eT>&& error,
119 arma::Mat<eT>&& gradient);
137 OutputDataType
const&
Delta()
const {
return delta; }
139 OutputDataType&
Delta() {
return delta; }
142 OutputDataType
const&
Gradient()
const {
return gradient; }
167 arma::mat&
Bias() {
return bias; }
172 template<
typename Archive>
173 void serialize(Archive& ar,
const unsigned int );
185 size_t TransposedConvOutSize(
const size_t size,
190 size_t out = std::floor(size - k + 2 * p) / s;
191 return out * s + 2 * (k - p) - 1 + ((((size + 2 * p - k) % s) + s) % s);
200 template<
typename eT>
201 void Rotate180(
const arma::Cube<eT>& input, arma::Cube<eT>& output)
203 output = arma::Cube<eT>(input.n_rows, input.n_cols, input.n_slices);
206 for (
size_t s = 0; s < output.n_slices; s++)
207 output.slice(s) = arma::fliplr(arma::flipud(input.slice(s)));
216 template<
typename eT>
217 void Rotate180(
const arma::Mat<eT>& input, arma::Mat<eT>& output)
220 output = arma::fliplr(arma::flipud(input));
251 OutputDataType weights;
272 arma::cube outputTemp;
275 arma::cube inputTemp;
278 arma::cube inputPaddedTemp;
284 arma::cube gradientTemp;
290 OutputDataType delta;
293 OutputDataType gradient;
296 InputDataType inputParameter;
299 OutputDataType outputParameter;
306 #include "transposed_convolution_impl.hpp" arma::mat & Bias()
Modify the bias weights of the layer.
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 & Gradient() const
Get the gradient.
OutputDataType & Parameters()
Modify the parameters.
size_t const & OutputHeight() const
Get the output height.
size_t const & InputHeight() const
Get the input height.
Implementation of the Padding module class.
OutputDataType & Delta()
Modify the delta.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t & InputHeight()
Modify the input height.
OutputDataType const & OutputParameter() const
Get the output 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.
size_t const & InputWidth() const
Get the input width.
size_t const & OutputWidth() const
Get the output width.
TransposedConvolution()
Create the Transposed Convolution object.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
OutputDataType & Gradient()
Modify the gradient.
InputDataType const & InputParameter() const
Get the input parameter.
OutputDataType const & Delta() const
Get the delta.
size_t & OutputWidth()
Modify the output width.
size_t & InputWidth()
Modify input the width.
OutputDataType & OutputParameter()
Modify the output parameter.
InputDataType & InputParameter()
Modify the input parameter.
size_t & OutputHeight()
Modify the output height.