GClasses
GClasses::GMaxPooling2D Class Reference

#include <GBlock.h>

Inheritance diagram for GClasses::GMaxPooling2D:
GClasses::GBlockWeightless GClasses::GBlock

Public Member Functions

 GMaxPooling2D (size_t inputCols, size_t inputRows, size_t inputChannels, size_t regionSize=2)
 General-purpose constructor. For example, if your input is a 64x48 color (RGB) image, then inputCols will be 64, inputRows will be 48, and inputChannels will be 3. The total input size will be 9216 (64*48*3=9216). The values should be presented in the following order: c1x1y1, c2x1y1, c1x2y1, c2x2y1, c1x1y2, ... If kernelSize is 5, then the output will consist of 60 columns (64-5+1=60) and 44 rows (48-5+1=44). If kernelsPerChannel is 2, then there will be 6 (3*2=6) channels in the output, for a total of 15840 (60*44*6=15840) output values. (kernelSize must be <= inputSamples.) More...
 
 GMaxPooling2D (GDomNode *pNode)
 Deserializing constructor. More...
 
virtual ~GMaxPooling2D ()
 
virtual void backProp (GContext &ctx, const GVec &input, const GVec &output, const GVec &outBlame, GVec &inBlame) const override
 Evaluates outBlame, and adds to inBlame. (Note that it "adds to" the inBlame because multiple blocks may fork from a common source.) More...
 
virtual void forwardProp (GContext &ctx, const GVec &input, GVec &output) const override
 Evaluate the input, set the output. More...
 
virtual size_t inputs () const override
 Returns the number of inputs this block consumes. More...
 
virtual std::string name () const override
 Returns the name of this block. More...
 
virtual size_t outputs () const override
 Returns the number of outputs this block produces. More...
 
virtual void resize (size_t inputs, size_t outputs) override
 Resizes this block. More...
 
virtual GDomNodeserialize (GDom *pDoc) const override
 Marshall this block into a DOM. More...
 
virtual BlockType type () const override
 Returns the type of this block. More...
 
- Public Member Functions inherited from GClasses::GBlockWeightless
 GBlockWeightless ()
 
 GBlockWeightless (GDomNode *pNode)
 
virtual ~GBlockWeightless ()
 
virtual void copyWeights (const GBlock *pSource) override
 Copy the weights from pSource to this block. (Assumes pSource is the same type of block.) More...
 
virtual void diminishWeights (double amount, bool regularizeBiases) override
 Moves all weights in the direction of zero by the specified amount. More...
 
virtual void maxNorm (double min, double max) override
 Scales weights if necessary such that the manitude of the weights (not including the bias) feeding into each unit are >= min and <= max. More...
 
virtual void perturbWeights (GRand &rand, double deviation) override
 Perturbs the weights that feed into the specifed units with Gaussian noise. The default values apply the perturbation to all units. More...
 
virtual void resetWeights (GRand &rand) override
 Initialize the weights, usually with small random values. More...
 
virtual void scaleWeights (double factor, bool scaleBiases) override
 Multiplies all the weights by the specified factor. More...
 
virtual void step (double learningRate, const GVec &gradient) override
 Add the weight and bias gradient to the weights. More...
 
virtual void updateGradient (GContext &ctx, const GVec &input, const GVec &outBlame, GVec &gradient) const override
 Evaluate the input and outBlame, update the gradient for updating the weights by gradient descent. More...
 
virtual size_t vectorToWeights (const double *pVector) override
 Deserialize from a vector to the weights in this block. Return the number of elements consumed. More...
 
virtual size_t weightCount () const override
 Returns the number of double-precision elements necessary to serialize the weights of this block into a vector. More...
 
virtual size_t weightsToVector (double *pOutVector) const override
 Serialize the weights in this block into a vector. Return the number of elements written. More...
 
- Public Member Functions inherited from GClasses::GBlock
 GBlock ()
 
 GBlock (GDomNode *pNode)
 
virtual ~GBlock ()
 
virtual bool elementWise () const
 Returns true iff this block operates only on individual elements. More...
 
size_t inPos () const
 Returns the offset in the previous layer's output where values are fed as input to this block. More...
 
virtual bool isRecurrent () const
 Returns true iff this block is recurrent. More...
 
void setInPos (size_t n)
 Sets the starting offset in the previous layer's output where values will be fed as input to this block. More...
 
virtual std::string to_str () const
 Returns a string representation of this block. More...
 
virtual bool usesGPU ()
 Returns true iff this block does its computations in parallel on a GPU. More...
 

Protected Attributes

size_t m_inputChannels
 
size_t m_inputCols
 
size_t m_inputRows
 
size_t m_regionSize
 
- Protected Attributes inherited from GClasses::GBlock
size_t m_inPos
 

Additional Inherited Members

- Public Types inherited from GClasses::GBlock
- Static Public Member Functions inherited from GClasses::GBlock
static GBlockdeserialize (GDomNode *pNode)
 Unmarshalls the specified DOM node into a block object. More...
 
- Protected Member Functions inherited from GClasses::GBlock
GDomNodebaseDomNode (GDom *pDoc) const
 
void basicTest ()
 Exercises some basic functionality that all blocks have in common. More...
 

Constructor & Destructor Documentation

GClasses::GMaxPooling2D::GMaxPooling2D ( size_t  inputCols,
size_t  inputRows,
size_t  inputChannels,
size_t  regionSize = 2 
)

General-purpose constructor. For example, if your input is a 64x48 color (RGB) image, then inputCols will be 64, inputRows will be 48, and inputChannels will be 3. The total input size will be 9216 (64*48*3=9216). The values should be presented in the following order: c1x1y1, c2x1y1, c1x2y1, c2x2y1, c1x1y2, ... If kernelSize is 5, then the output will consist of 60 columns (64-5+1=60) and 44 rows (48-5+1=44). If kernelsPerChannel is 2, then there will be 6 (3*2=6) channels in the output, for a total of 15840 (60*44*6=15840) output values. (kernelSize must be <= inputSamples.)

GClasses::GMaxPooling2D::GMaxPooling2D ( GDomNode pNode)

Deserializing constructor.

virtual GClasses::GMaxPooling2D::~GMaxPooling2D ( )
virtual

Member Function Documentation

virtual void GClasses::GMaxPooling2D::backProp ( GContext ctx,
const GVec input,
const GVec output,
const GVec outBlame,
GVec inBlame 
) const
overridevirtual

Evaluates outBlame, and adds to inBlame. (Note that it "adds to" the inBlame because multiple blocks may fork from a common source.)

Implements GClasses::GBlock.

virtual void GClasses::GMaxPooling2D::forwardProp ( GContext ctx,
const GVec input,
GVec output 
) const
overridevirtual

Evaluate the input, set the output.

Implements GClasses::GBlock.

virtual size_t GClasses::GMaxPooling2D::inputs ( ) const
inlineoverridevirtual

Returns the number of inputs this block consumes.

Implements GClasses::GBlock.

virtual std::string GClasses::GMaxPooling2D::name ( ) const
inlineoverridevirtual

Returns the name of this block.

Implements GClasses::GBlock.

virtual size_t GClasses::GMaxPooling2D::outputs ( ) const
inlineoverridevirtual

Returns the number of outputs this block produces.

Implements GClasses::GBlock.

virtual void GClasses::GMaxPooling2D::resize ( size_t  inputs,
size_t  outputs 
)
overridevirtual

Resizes this block.

Implements GClasses::GBlock.

virtual GDomNode* GClasses::GMaxPooling2D::serialize ( GDom pDoc) const
overridevirtual

Marshall this block into a DOM.

Implements GClasses::GBlock.

virtual BlockType GClasses::GMaxPooling2D::type ( ) const
inlineoverridevirtual

Returns the type of this block.

Implements GClasses::GBlock.

Member Data Documentation

size_t GClasses::GMaxPooling2D::m_inputChannels
protected
size_t GClasses::GMaxPooling2D::m_inputCols
protected
size_t GClasses::GMaxPooling2D::m_inputRows
protected
size_t GClasses::GMaxPooling2D::m_regionSize
protected