13 #ifndef MLPACK_METHODS_ANN_LAYER_ADAPTIVE_MEAN_POOLING_HPP 14 #define MLPACK_METHODS_ANN_LAYER_ADAPTIVE_MEAN_POOLING_HPP 31 typename InputDataType = arma::mat,
32 typename OutputDataType = arma::mat
47 const size_t outputHeight);
64 void Forward(
const arma::Mat<eT>& input, arma::Mat<eT>& output);
76 void Backward(
const arma::Mat<eT>& input,
77 const arma::Mat<eT>& gy,
82 {
return poolingLayer.OutputParameter(); }
88 const OutputDataType&
Delta()
const {
return poolingLayer.Delta(); }
90 OutputDataType&
Delta() {
return poolingLayer.Delta(); }
93 size_t InputWidth()
const {
return poolingLayer.InputWidth(); }
95 size_t&
InputWidth() {
return poolingLayer.InputWidth(); }
98 size_t InputHeight()
const {
return poolingLayer.InputHeight(); }
113 size_t InputSize()
const {
return poolingLayer.InputSize(); }
116 size_t OutputSize()
const {
return poolingLayer.OutputSize(); }
124 template<
typename Archive>
125 void serialize(Archive& ar,
const uint32_t version);
131 void IntializeAdaptivePadding()
133 poolingLayer.StrideWidth() = std::floor(poolingLayer.InputWidth() /
135 poolingLayer.StrideHeight() = std::floor(poolingLayer.InputHeight() /
138 poolingLayer.KernelWidth() = poolingLayer.InputWidth() -
139 (outputWidth - 1) * poolingLayer.StrideWidth();
140 poolingLayer.KernelHeight() = poolingLayer.InputHeight() -
141 (outputHeight - 1) * poolingLayer.StrideHeight();
143 if (poolingLayer.KernelHeight() <= 0 || poolingLayer.KernelWidth() <= 0 ||
144 poolingLayer.StrideWidth() <= 0 || poolingLayer.StrideHeight() <= 0)
146 Log::Fatal <<
"Given output shape (" << outputWidth <<
", " 147 << outputHeight <<
") is not possible for given input shape (" 148 << poolingLayer.InputWidth() <<
", " << poolingLayer.InputHeight()
149 <<
")." << std::endl;
void serialize(Archive &ar, const uint32_t version)
Serialize the layer.
Definition: adaptive_mean_pooling_impl.hpp:72
size_t & InputHeight()
Modify the input height.
Definition: adaptive_mean_pooling.hpp:100
size_t OutputWidth() const
Get the output width.
Definition: adaptive_mean_pooling.hpp:103
size_t & InputWidth()
Modify the input width.
Definition: adaptive_mean_pooling.hpp:95
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
Definition: log.hpp:90
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: adaptive_mean_pooling.hpp:85
OutputDataType & Delta()
Modify the delta.
Definition: adaptive_mean_pooling.hpp:90
Implementation of the MeanPooling.
Definition: mean_pooling.hpp:33
size_t OutputHeight() const
Get the output height.
Definition: adaptive_mean_pooling.hpp:108
Implementation of the AdaptiveMeanPooling.
Definition: adaptive_mean_pooling.hpp:34
size_t & OutputWidth()
Modify the output width.
Definition: adaptive_mean_pooling.hpp:105
size_t OutputSize() const
Get the output size.
Definition: adaptive_mean_pooling.hpp:116
size_t InputSize() const
Get the input size.
Definition: adaptive_mean_pooling.hpp:113
const OutputDataType & Delta() const
Get the delta.
Definition: adaptive_mean_pooling.hpp:88
size_t InputHeight() const
Get the input height.
Definition: adaptive_mean_pooling.hpp:98
size_t & OutputHeight()
Modify the output height.
Definition: adaptive_mean_pooling.hpp:110
AdaptiveMeanPooling()
Create the AdaptiveMeanPooling object.
Definition: adaptive_mean_pooling_impl.hpp:22
void Backward(const arma::Mat< eT > &input, const arma::Mat< eT > &gy, arma::Mat< eT > &g)
Ordinary feed backward pass of a neural network, using 3rd-order tensors as input, calculating the function f(x) by propagating x backwards through f.
Definition: adaptive_mean_pooling_impl.hpp:62
size_t InputWidth() const
Get the input width.
Definition: adaptive_mean_pooling.hpp:93
const OutputDataType & OutputParameter() const
Get the output parameter.
Definition: adaptive_mean_pooling.hpp:81
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...
Definition: adaptive_mean_pooling_impl.hpp:48
size_t WeightSize() const
Get the size of the weights.
Definition: adaptive_mean_pooling.hpp:119