12 #ifndef MLPACK_METHODS_ANN_LAYER_ADAPTIVE_MAX_POOLING_HPP
13 #define MLPACK_METHODS_ANN_LAYER_ADAPTIVE_MAX_POOLING_HPP
30 typename InputDataType = arma::mat,
31 typename OutputDataType = arma::mat
46 const size_t outputHeight);
63 void Forward(
const arma::Mat<eT>& input, arma::Mat<eT>& output);
76 const arma::Mat<eT>& gy,
81 {
return poolingLayer.OutputParameter(); }
87 const OutputDataType&
Delta()
const {
return poolingLayer.Delta(); }
89 OutputDataType&
Delta() {
return poolingLayer.Delta(); }
92 size_t InputWidth()
const {
return poolingLayer.InputWidth(); }
94 size_t&
InputWidth() {
return poolingLayer.InputWidth(); }
97 size_t InputHeight()
const {
return poolingLayer.InputHeight(); }
112 size_t InputSize()
const {
return poolingLayer.InputSize(); }
115 size_t OutputSize()
const {
return poolingLayer.OutputSize(); }
120 template<
typename Archive>
121 void serialize(Archive& ar,
const unsigned int version);
127 void IntializeAdaptivePadding()
129 poolingLayer.StrideWidth() = std::floor(poolingLayer.InputWidth() /
131 poolingLayer.StrideHeight() = std::floor(poolingLayer.InputHeight() /
134 poolingLayer.KernelWidth() = poolingLayer.InputWidth() -
135 (outputWidth - 1) * poolingLayer.StrideWidth();
136 poolingLayer.KernelHeight() = poolingLayer.InputHeight() -
137 (outputHeight - 1) * poolingLayer.StrideHeight();
139 if (poolingLayer.KernelHeight() <= 0 || poolingLayer.KernelWidth() <= 0 ||
140 poolingLayer.StrideWidth() <= 0 || poolingLayer.StrideHeight() <= 0)
142 Log::Fatal <<
"Given output shape (" << outputWidth <<
", "
143 << outputHeight <<
") is not possible for given input shape ("
144 << poolingLayer.InputWidth() <<
", " << poolingLayer.InputHeight()
145 <<
")." << std::endl;
150 MaxPooling<InputDataType, OutputDataType> poolingLayer;
166 #include "adaptive_max_pooling_impl.hpp"