GClasses
|
#include <GBlock.h>
Public Member Functions | |
GBlockConvolutional1D (size_t inputSamples, size_t inputChannels, size_t kernelSize, size_t kernelsPerChannel) | |
General-purpose constructor. For example, if you collect 19 samples from 3 sensors, then the total input size will be 57 (19*3=57). The three values collected at time 0 will come first, followed by the three values collected at time 1, and so forth. If kernelSize is 5, then the output will consist of 15 (19-5+1=15) samples. If kernelsPerChannel is 2, then there will be 6 (3*2=6) channels in the output, for a total of 90 (15*6=90) output values. The first six channel values will appear first in the output vector, followed by the next six, and so forth. (kernelSize must be <= inputSamples.) More... | |
GBlockConvolutional1D (GDomNode *pNode) | |
Deserializing constructor. More... | |
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... | |
const GVec & | bias () const |
GVec & | bias () |
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 |
Diminishes all the weights (that is, moves them in the direction toward 0) by the specified amount. 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... | |
const GMatrix & | kernels () const |
GMatrix & | kernels () |
virtual void | maxNorm (double min, double max) override |
Clips each kernel weight (not including the bias) to fall between -max and max. 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 | perturbWeights (GRand &rand, double deviation) override |
Perturbs the weights that feed into the specifed units with Gaussian noise. start specifies the first unit whose incoming weights are perturbed. count specifies the maximum number of units whose incoming weights are perturbed. More... | |
virtual void | resetWeights (GRand &rand) override |
Initialize the weights with small random values. More... | |
virtual void | resize (size_t inputs, size_t outputs) override |
Resizes this block. More... | |
virtual void | scaleWeights (double factor, bool scaleBiases) override |
Multiplies all the weights in this block by the specified factor. More... | |
virtual GDomNode * | serialize (GDom *pDoc) const override |
Marshall this block into a DOM. More... | |
virtual void | step (double learningRate, const GVec &gradient) override |
Add the weight and bias gradient to the weights. More... | |
virtual BlockType | type () const override |
Returns the type of this block. More... | |
virtual void | updateGradient (GContext &ctx, const GVec &input, const GVec &outBlame, GVec &gradient) const override |
Updates the gradient for updating the weights by gradient descent. (Assumes the error has already been computed and deactivated.) 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 | |
GVec | m_bias |
size_t | m_inputChannels |
size_t | m_inputSamples |
GMatrix | m_kernels |
size_t | m_kernelsPerChannel |
size_t | m_outputSamples |
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 GBlock * | deserialize (GDomNode *pNode) |
Unmarshalls the specified DOM node into a block object. More... | |
Protected Member Functions inherited from GClasses::GBlock | |
GDomNode * | baseDomNode (GDom *pDoc) const |
void | basicTest () |
Exercises some basic functionality that all blocks have in common. More... | |
GClasses::GBlockConvolutional1D::GBlockConvolutional1D | ( | size_t | inputSamples, |
size_t | inputChannels, | ||
size_t | kernelSize, | ||
size_t | kernelsPerChannel | ||
) |
General-purpose constructor. For example, if you collect 19 samples from 3 sensors, then the total input size will be 57 (19*3=57). The three values collected at time 0 will come first, followed by the three values collected at time 1, and so forth. If kernelSize is 5, then the output will consist of 15 (19-5+1=15) samples. If kernelsPerChannel is 2, then there will be 6 (3*2=6) channels in the output, for a total of 90 (15*6=90) output values. The first six channel values will appear first in the output vector, followed by the next six, and so forth. (kernelSize must be <= inputSamples.)
GClasses::GBlockConvolutional1D::GBlockConvolutional1D | ( | GDomNode * | pNode | ) |
Deserializing constructor.
|
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.
|
inline |
|
inline |
|
overridevirtual |
Copy the weights from pSource to this block. (Assumes pSource is the same type of block.)
Implements GClasses::GBlock.
|
overridevirtual |
Diminishes all the weights (that is, moves them in the direction toward 0) by the specified amount.
Implements GClasses::GBlock.
|
overridevirtual |
Evaluate the input, set the output.
Implements GClasses::GBlock.
|
inlineoverridevirtual |
Returns the number of inputs this block consumes.
Implements GClasses::GBlock.
|
inline |
|
inline |
|
overridevirtual |
Clips each kernel weight (not including the bias) to fall between -max and max.
Implements GClasses::GBlock.
|
inlineoverridevirtual |
Returns the name of this block.
Implements GClasses::GBlock.
|
inlineoverridevirtual |
Returns the number of outputs this block produces.
Implements GClasses::GBlock.
|
overridevirtual |
Perturbs the weights that feed into the specifed units with Gaussian noise. start specifies the first unit whose incoming weights are perturbed. count specifies the maximum number of units whose incoming weights are perturbed.
Implements GClasses::GBlock.
|
overridevirtual |
Initialize the weights with small random values.
Implements GClasses::GBlock.
|
overridevirtual |
Resizes this block.
Implements GClasses::GBlock.
|
overridevirtual |
Multiplies all the weights in this block by the specified factor.
Implements GClasses::GBlock.
Marshall this block into a DOM.
Implements GClasses::GBlock.
|
overridevirtual |
Add the weight and bias gradient to the weights.
Implements GClasses::GBlock.
|
inlineoverridevirtual |
Returns the type of this block.
Implements GClasses::GBlock.
|
overridevirtual |
Updates the gradient for updating the weights by gradient descent. (Assumes the error has already been computed and deactivated.)
Implements GClasses::GBlock.
|
overridevirtual |
Deserialize from a vector to the weights in this block. Return the number of elements consumed.
Implements GClasses::GBlock.
|
overridevirtual |
Returns the number of double-precision elements necessary to serialize the weights of this block into a vector.
Implements GClasses::GBlock.
|
overridevirtual |
Serialize the weights in this block into a vector. Return the number of elements written.
Implements GClasses::GBlock.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |