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);
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(); }
121 template<
typename Archive>
122 void serialize(Archive& ar,
const unsigned int version);
128 void IntializeAdaptivePadding()
130 poolingLayer.StrideWidth() = std::floor(poolingLayer.InputWidth() /
132 poolingLayer.StrideHeight() = std::floor(poolingLayer.InputHeight() /
135 poolingLayer.KernelWidth() = poolingLayer.InputWidth() -
136 (outputWidth - 1) * poolingLayer.StrideWidth();
137 poolingLayer.KernelHeight() = poolingLayer.InputHeight() -
138 (outputHeight - 1) * poolingLayer.StrideHeight();
140 if (poolingLayer.KernelHeight() <= 0 || poolingLayer.KernelWidth() <= 0 ||
141 poolingLayer.StrideWidth() <= 0 || poolingLayer.StrideHeight() <= 0)
143 Log::Fatal <<
"Given output shape (" << outputWidth <<
", "
144 << outputHeight <<
") is not possible for given input shape ("
145 << poolingLayer.InputWidth() <<
", " << poolingLayer.InputHeight()
146 <<
")." << std::endl;
151 MeanPooling<InputDataType, OutputDataType> poolingLayer;
167#include "adaptive_mean_pooling_impl.hpp"
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
Implementation of the AdaptiveMeanPooling.
AdaptiveMeanPooling()
Create the AdaptiveMeanPooling object.
size_t & InputHeight()
Modify the input height.
AdaptiveMeanPooling(const std::tuple< size_t, size_t > &outputShape)
Create the AdaptiveMeanPooling object.
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...
size_t InputSize() const
Get the input size.
size_t & InputWidth()
Modify the input width.
void serialize(Archive &ar, const unsigned int version)
Serialize the layer.
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,...
size_t & OutputHeight()
Modify the output height.
size_t OutputHeight() const
Get the output height.
size_t OutputSize() const
Get the output size.
size_t OutputWidth() const
Get the output width.
AdaptiveMeanPooling(const size_t outputWidth, const size_t outputHeight)
Create the AdaptiveMeanPooling object.
size_t InputHeight() const
Get the input height.
const OutputDataType & OutputParameter() const
Get the output parameter.
OutputDataType & OutputParameter()
Modify the output parameter.
size_t & OutputWidth()
Modify the output width.
OutputDataType & Delta()
Modify the delta.
const OutputDataType & Delta() const
Get the delta.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.