27 #ifndef MAXPOOLLAYER_H_ 28 #define MAXPOOLLAYER_H_ 53 template <
typename Architecture_t>
56 using Matrix_t =
typename Architecture_t::Matrix_t;
57 using Scalar_t =
typename Architecture_t::Scalar_t;
75 TMaxPoolLayer(
size_t BatchSize,
size_t InputDepth,
size_t InputHeight,
size_t InputWidth,
size_t Height,
76 size_t Width,
size_t OutputNSlices,
size_t OutputNRows,
size_t OutputNCols,
size_t FrameHeight,
77 size_t FrameWidth,
size_t StrideRows,
size_t StrideCols,
Scalar_t DropoutProbability);
92 void Forward(std::vector<Matrix_t> &input,
bool applyDropout =
false);
98 void Backward(std::vector<Matrix_t> &gradients_backward,
const std::vector<Matrix_t> &activations_backward,
99 std::vector<Matrix_t> &inp1, std::vector<Matrix_t> &inp2);
128 template <
typename Architecture_t>
130 size_t height,
size_t width,
size_t outputNSlices,
size_t outputNRows,
131 size_t outputNCols,
size_t frameHeight,
size_t frameWidth,
132 size_t strideRows,
size_t strideCols,
Scalar_t dropoutProbability)
133 :
VGeneralLayer<Architecture_t>(batchSize, inputDepth, inputHeight, inputWidth, inputDepth, height, width, 0, 0, 0,
145 template <
typename Architecture_t>
158 template <
typename Architecture_t>
165 for (
size_t i = 0; i < layer.
fBatchSize; i++) {
171 template <
typename Architecture_t>
177 template <
typename Architecture_t>
193 template <
typename Architecture_t>
195 const std::vector<Matrix_t> & ,
196 std::vector<Matrix_t> & , std::vector<Matrix_t> &
204 template <
typename Architecture_t>
207 std::cout <<
" POOL Layer: \t";
208 std::cout <<
"( W = " << this->
GetWidth() <<
" , ";
209 std::cout <<
" H = " << this->
GetHeight() <<
" , ";
210 std::cout <<
" D = " << this->
GetDepth() <<
" ) ";
212 std::cout <<
"\t Frame ( W = " << this->
GetFrameWidth() <<
" , ";
216 std::cout <<
"\tOutput = ( " << this->
GetOutput().size() <<
" , " << this->
GetOutput()[0].GetNrows() <<
" , " << this->
GetOutput()[0].GetNcols() <<
" ) ";
218 std::cout << std::endl;
222 template <
typename Architecture_t>
236 template <
typename Architecture_t>
size_t GetInputWidth() const
Generic General Layer class.
size_t fDepth
The depth of the layer.
~TMaxPoolLayer()
Destructor.
size_t fStrideRows
The number of row pixels to slid the filter each step.
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
Generic Max Pooling Layer class.
size_t GetFrameWidth() const
size_t GetStrideCols() const
size_t fNLocalViews
The number of local views in one image.
size_t fStrideCols
The number of column pixels to slid the filter each step.
Matrix_t & GetOutputAt(size_t i)
void Backward(std::vector< Matrix_t > &gradients_backward, const std::vector< Matrix_t > &activations_backward, std::vector< Matrix_t > &inp1, std::vector< Matrix_t > &inp2)
Depending on the winning units determined during the Forward pass, it only forwards the derivatives t...
size_t GetBatchSize() const
Getters.
size_t GetFrameHeight() const
const std::vector< Matrix_t > & GetActivationGradients() const
virtual void ReadWeightsFromXML(void *parent)
Read the information and the weights about the layer from XML node.
const std::vector< Matrix_t > & GetIndexMatrix() const
Getters.
void Print() const
Prints the info about the layer.
size_t GetNLocalViewPixels() const
size_t fFrameHeight
The height of the frame.
typename Architecture_t::Scalar_t Scalar_t
virtual void AddWeightsXMLTo(void *parent)
Writes the information and the weights about the layer in an XML node.
size_t GetInputHeight() const
TMaxPoolLayer(size_t BatchSize, size_t InputDepth, size_t InputHeight, size_t InputWidth, size_t Height, size_t Width, size_t OutputNSlices, size_t OutputNRows, size_t OutputNCols, size_t FrameHeight, size_t FrameWidth, size_t StrideRows, size_t StrideCols, Scalar_t DropoutProbability)
Constructor.
Scalar_t fDropoutProbability
Probability that an input is active.
size_t fNLocalViewPixels
The number of pixels in one local image view.
std::vector< Matrix_t > indexMatrix
Matrix of indices for the backward pass.
XMLAttrPointer_t NewAttr(XMLNodePointer_t xmlnode, XMLNsPointer_t, const char *name, const char *value)
creates new attribute for xmlnode, namespaces are not supported for attributes
size_t fBatchSize
Batch size used for training and evaluation.
size_t GetStrideRows() const
size_t GetNLocalViews() const
typename Architecture_t::Matrix_t Matrix_t
Abstract ClassifierFactory template that handles arbitrary types.
std::vector< Matrix_t > & GetIndexMatrix()
void Forward(std::vector< Matrix_t > &input, bool applyDropout=false)
Computes activation of the layer for the given input.
XMLNodePointer_t NewChild(XMLNodePointer_t parent, XMLNsPointer_t ns, const char *name, const char *content=0)
create new child element for parent node
const std::vector< Matrix_t > & GetOutput() const
size_t fFrameWidth
The width of the frame.
Scalar_t GetDropoutProbability() const