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;
170 #include "adaptive_mean_pooling_impl.hpp" size_t & OutputHeight()
Modify the output height.
size_t & InputWidth()
Modify the input width.
size_t OutputHeight() const
Get the output height.
Linear algebra utility functions, generally performed on matrices or vectors.
size_t InputWidth() const
Get the input width.
The core includes that mlpack expects; standard C++ includes and Armadillo.
Implementation of the MeanPooling.
size_t OutputWidth() const
Get the output width.
OutputDataType & OutputParameter()
Modify the output parameter.
size_t WeightSize() const
Get the size of the weights.
Implementation of the AdaptiveMeanPooling.
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
const OutputDataType & Delta() const
Get the delta.
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...
const OutputDataType & OutputParameter() const
Get the output parameter.
void serialize(Archive &ar, const uint32_t version)
Serialize the layer.
size_t & InputHeight()
Modify the input height.
size_t InputSize() const
Get the input size.
OutputDataType & Delta()
Modify the delta.
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.
size_t OutputSize() const
Get the output size.
size_t InputHeight() const
Get the input height.
size_t & OutputWidth()
Modify the output width.
AdaptiveMeanPooling()
Create the AdaptiveMeanPooling object.