GClasses
GClasses::GBlockRecurrent Class Referenceabstract

Detailed Description

Base class of recurrent blocks.

#include <GBlock.h>

Inheritance diagram for GClasses::GBlockRecurrent:
GClasses::GBlock GClasses::GBlockGRU GClasses::GBlockLSTM

Public Member Functions

 GBlockRecurrent ()
 
 GBlockRecurrent (GDomNode *pNode)
 
virtual ~GBlockRecurrent ()
 
virtual size_t depth ()=0
 Returns the number of instances of this block unfolded through time that will be used during training. More...
 
virtual bool isRecurrent () const override
 Returns true. More...
 
virtual GContextRecurrentInstancenewContext (GRand &rand)=0
 Returns a new context object for this recurrent block. The recurrent state should be initialized to the starting state. More...
 
- Public Member Functions inherited from GClasses::GBlock
 GBlock ()
 
 GBlock (GDomNode *pNode)
 
virtual ~GBlock ()
 
virtual void copyWeights (const GBlock *pSource)=0
 Copy the weights from pSource to this block. (Assumes pSource is the same type of block.) More...
 
virtual void diminishWeights (double amount, bool regularizeBiases)=0
 Moves all weights in the direction of zero by the specified amount. More...
 
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 size_t inputs () const =0
 Returns the number of inputs this block consumes. More...
 
virtual void maxNorm (double min, double max)=0
 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 std::string name () const =0
 Returns the name of this block in the form of a string. More...
 
virtual size_t outputs () const =0
 Returns the number of outputs this block produces. More...
 
virtual void perturbWeights (GRand &rand, double deviation)=0
 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)=0
 Initialize the weights, usually with small random values. More...
 
virtual void resize (size_t inputs, size_t outputs)=0
 Resizes this block. More...
 
virtual void scaleWeights (double factor, bool scaleBiases)=0
 Multiplies all the weights by the specified factor. More...
 
virtual GDomNodeserialize (GDom *pDoc) const =0
 Marshall this block into a DOM. 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 void step (double learningRate, const GVec &gradient)=0
 Add the weight and bias gradient to the weights. More...
 
virtual std::string to_str () const
 Returns a string representation of this block. More...
 
virtual BlockType type () const =0
 Returns the type of this block. More...
 
virtual bool usesGPU ()
 Returns true iff this block does its computations in parallel on a GPU. More...
 
virtual size_t vectorToWeights (const double *pVector)=0
 Deserialize from a vector to the weights in this block. Return the number of elements consumed. More...
 
virtual size_t weightCount () const =0
 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 =0
 Serialize the weights in this block into a vector. Return the number of elements written. More...
 

Protected Member Functions

virtual void backProp (GContext &ctx, const GVec &input, const GVec &output, const GVec &outBlame, GVec &inBlame) const override
 Deliberately protected. Throws an exception telling you to call GContextRecurrent::backProp instead. More...
 
virtual void forwardProp (GContext &ctx, const GVec &input, GVec &output) const override
 Deliberately protected. Throws an exception telling you to call GContextRecurrent::forwardProp instead. More...
 
virtual void updateGradient (GContext &ctx, const GVec &input, const GVec &outBlame, GVec &gradient) const override
 Deliberately protected. Throws an exception telling you to call GContextRecurrent::updateGradient instead. 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...
 

Static Protected Member Functions

static double testEngine (GNeuralNet &nn)
 

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 Attributes inherited from GClasses::GBlock
size_t m_inPos
 

Constructor & Destructor Documentation

GClasses::GBlockRecurrent::GBlockRecurrent ( )
inline
GClasses::GBlockRecurrent::GBlockRecurrent ( GDomNode pNode)
inline
virtual GClasses::GBlockRecurrent::~GBlockRecurrent ( )
inlinevirtual

Member Function Documentation

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

Deliberately protected. Throws an exception telling you to call GContextRecurrent::backProp instead.

Implements GClasses::GBlock.

virtual size_t GClasses::GBlockRecurrent::depth ( )
pure virtual

Returns the number of instances of this block unfolded through time that will be used during training.

Implemented in GClasses::GBlockGRU, and GClasses::GBlockLSTM.

virtual void GClasses::GBlockRecurrent::forwardProp ( GContext ctx,
const GVec input,
GVec output 
) const
overrideprotectedvirtual

Deliberately protected. Throws an exception telling you to call GContextRecurrent::forwardProp instead.

Implements GClasses::GBlock.

virtual bool GClasses::GBlockRecurrent::isRecurrent ( ) const
inlineoverridevirtual

Returns true.

Reimplemented from GClasses::GBlock.

virtual GContextRecurrentInstance* GClasses::GBlockRecurrent::newContext ( GRand rand)
pure virtual

Returns a new context object for this recurrent block. The recurrent state should be initialized to the starting state.

Implemented in GClasses::GBlockGRU, and GClasses::GBlockLSTM.

static double GClasses::GBlockRecurrent::testEngine ( GNeuralNet nn)
staticprotected
virtual void GClasses::GBlockRecurrent::updateGradient ( GContext ctx,
const GVec input,
const GVec outBlame,
GVec gradient 
) const
overrideprotectedvirtual

Deliberately protected. Throws an exception telling you to call GContextRecurrent::updateGradient instead.

Implements GClasses::GBlock.