![]() |
Deepity
Ultra-fast, SIMD-accelerated Predictive Coding
|
Convolutional Predictive Coding layer (im2col-based). See the file-level warning above before enabling an unclamped middle layer. More...
#include <ConvPCLayer.h>
Public Member Functions | |
| ConvPCLayer (int inChannels, int outChannels, int inHeight, int inWidth, int kernelH, int kernelW, int strideH=1, int strideW=1, int padH=0, int padW=0, int batchSize=1, float learningRate=1e-6f, float inferenceRate=0.1f, float precisionRate=0.01f, float lmbda=1e-2f, ActivationType aType=ActivationType::RELU, ActivationType dType=ActivationType::dRELU) | |
| Constructor for a convolutional PC layer. | |
| float | CalculateState () noexcept override |
| Calculate energy/prediction errors for this layer. | |
| void | UpdateState () noexcept override |
| Update latent beliefs (z/r) via inference gradient. | |
| void | UpdateWeights () noexcept override |
| Hebbian/gradient weight update. | |
| void | UpdatePrecision () noexcept |
| Updates this layer's precision estimate from current prediction errors, using the configured precision rate (pr). | |
| void | Flush () noexcept override |
| No-op; exists for Layer interface conformance. | |
| void | ClampState (const std::vector< float > &inputData) noexcept |
| Clamps this layer's beliefs to externally-provided data, preventing them from being updated by UpdateState(). | |
| void | UnclampState () noexcept |
| Releases a previous ClampState() call, allowing this layer's beliefs to update normally again. | |
| float * | GetBeliefs () noexcept override |
| Returns this layer's belief buffer. | |
| const float * | GetErrors () const noexcept override |
| Returns this layer's prediction-error buffer. | |
| const float * | GetMu () const noexcept |
| Returns this layer's top-down prediction buffer. | |
| size_t | GetInputSize () const noexcept override |
| Flattened element count per batch item (inChannels*H*W). | |
| size_t | GetOutputSize () const noexcept override |
| Flattened element count of this layer's OUTGOING prediction (outChannels*outH*outW), 0 for a terminal layer. | |
| size_t | GetBatchSize () const noexcept override |
| Returns the batch size this layer was constructed with. | |
| const float * | GetWeights () const noexcept |
| Returns this layer's weight buffer. | |
| float * | GetWeights () noexcept |
| Returns this layer's weight buffer. | |
| const float * | GetBiases () const noexcept |
| Returns this layer's bias buffer. | |
| float * | GetBiases () noexcept |
| Returns this layer's bias buffer. | |
| const float * | GetPrecisions () const noexcept |
| Returns this layer's precision buffer. | |
| float | GetLearningRate () const noexcept |
| Returns the learning rate used for weight updates. | |
| float | GetInferenceRate () const noexcept |
| Returns the learning rate used for internal-state updates. | |
| float | GetPrecisionRate () const noexcept |
| Returns the learning rate used for precision updates. | |
| float | GetLambda () const noexcept |
| Returns the weight-decay (L2 regularization) coefficient. | |
| void | SetLearningRate (float lr) noexcept |
| Sets the learning rate used for weight updates. | |
| void | SetInferenceRate (float ir) noexcept |
| Sets the learning rate used for internal-state updates. | |
| void | SetPrecisionRate (float pr) noexcept |
| Sets the learning rate used for precision updates. | |
| void | SetLambda (float l) noexcept |
| Sets the weight-decay (L2 regularization) coefficient. | |
| void | SetLayerAbove (ConvPCLayer *above) noexcept |
| Sets the layer immediately above this one in the network. | |
| void | SetLayerBelow (ConvPCLayer *below) noexcept |
| Sets the layer immediately below this one in the network. | |
| void | ResetState () noexcept |
| Resets this layer's beliefs/errors back to their initial values, without touching learned weights. | |
| void | RandomizeWeights (std::mt19937 &twister) noexcept |
| Randomizes this layer's weights (and biases) in place. | |
| std::map< std::string, TensorDescriptor > | GetStateDict () const override |
| Returns a dictionary of this. | |
| void | ResyncLogPrecision () noexcept |
| Rebuilds log_p from p – required after a checkpoint load that only persists p (mirrors DiscriminativePCLayer's fix for the same p/log_p desync issue found in ModelIO::Load()). | |
| void | ComputeMuOnly () noexcept |
| Fast-path forward projection that skips state initialization. | |
| ActivationType | GetActivationType () const noexcept |
| Returns this layer's configured activation type. | |
| ActivationType | GetDerivativeType () const noexcept |
| Returns this layer's configured activation-derivative type. | |
| int | GetInChannels () const noexcept |
| Returns the number of input channels. | |
| int | GetOutChannels () const noexcept |
| Returns the number of output channels (0 for a terminal layer). | |
| int | GetInHeight () const noexcept |
| Returns the input feature-map height. | |
| int | GetInWidth () const noexcept |
| Returns the input feature-map width. | |
| int | GetOutHeight () const noexcept |
| Returns the output feature-map height. | |
| int | GetOutWidth () const noexcept |
| Returns the output feature-map width. | |
| int | GetKernelH () const noexcept |
| Returns the convolution kernel height. | |
| int | GetKernelW () const noexcept |
| Returns the convolution kernel width. | |
| size_t | GetRequiredFloats () const noexcept |
| Computes the total number of floats this layer requires from a MemoryArena (weights, biases, beliefs, errors, and every scratch buffer combined). | |
| void | BindMemory (MemoryArena &arena) |
| Binds this layer's weight/state/scratch buffers into the supplied arena. Must be called before any other operation. | |
| Public Member Functions inherited from Deep::Layer | |
| virtual | ~Layer ()=default |
Friends | |
| class | PCNDiagnostics |
Additional Inherited Members | |
| Protected Attributes inherited from Deep::Layer | |
| size_t | size |
| Size of input. | |
| size_t | nextSize |
| Size of output. | |
Convolutional Predictive Coding layer (im2col-based). See the file-level warning above before enabling an unclamped middle layer.
| Deep::ConvPCLayer::ConvPCLayer | ( | int | inChannels, |
| int | outChannels, | ||
| int | inHeight, | ||
| int | inWidth, | ||
| int | kernelH, | ||
| int | kernelW, | ||
| int | strideH = 1, | ||
| int | strideW = 1, | ||
| int | padH = 0, | ||
| int | padW = 0, | ||
| int | batchSize = 1, | ||
| float | learningRate = 1e-6f, | ||
| float | inferenceRate = 0.1f, | ||
| float | precisionRate = 0.01f, | ||
| float | lmbda = 1e-2f, | ||
| ActivationType | aType = ActivationType::RELU, | ||
| ActivationType | dType = ActivationType::dRELU ) |
Constructor for a convolutional PC layer.
| inChannels | Number of input channels |
| outChannels | Number of output channels (0 marks a terminal layer, matching DiscriminativePCLayer's convention where nextSize=0 means "no outgoing prediction") |
| inHeight | Input feature-map height |
| inWidth | Input feature-map width |
| kernelH | Kernel height |
| kernelW | Kernel width |
| strideH | Vertical stride |
| strideW | Horizontal stride |
| padH | Vertical zero-padding |
| padW | Horizontal zero-padding |
| batchSize | Batch size |
| learningRate | Learning rate for weights |
| inferenceRate | Learning rate for internal state |
| precisionRate | Learning rate for precision |
| lmbda | Weight decay (L2 regularization) coefficient |
| aType | Activation type |
| dType | Activation derivative type |
| void Deep::ConvPCLayer::BindMemory | ( | MemoryArena & | arena | ) |
Binds this layer's weight/state/scratch buffers into the supplied arena. Must be called before any other operation.
| arena | The MemoryArena to bind into. |
|
overridevirtualnoexcept |
Calculate energy/prediction errors for this layer.
Implements Deep::Layer.
|
noexcept |
Clamps this layer's beliefs to externally-provided data, preventing them from being updated by UpdateState().
| inputData | Flattened input data matching (inChannels, inHeight, inWidth) per batch item. |
|
noexcept |
Fast-path forward projection that skips state initialization.
|
inlineoverridevirtualnoexcept |
No-op; exists for Layer interface conformance.
Reimplemented from Deep::Layer.
|
inlinenoexcept |
Returns this layer's configured activation type.
|
inlineoverridevirtualnoexcept |
Returns the batch size this layer was constructed with.
Implements Deep::Layer.
|
inlineoverridevirtualnoexcept |
Returns this layer's belief buffer.
Implements Deep::Layer.
|
inlinenoexcept |
Returns this layer's bias buffer.
|
inlinenoexcept |
Returns this layer's bias buffer.
|
inlinenoexcept |
Returns this layer's configured activation-derivative type.
|
inlineoverridevirtualnoexcept |
Returns this layer's prediction-error buffer.
Implements Deep::Layer.
|
inlinenoexcept |
Returns the number of input channels.
|
inlinenoexcept |
Returns the learning rate used for internal-state updates.
|
inlinenoexcept |
Returns the input feature-map height.
|
inlineoverridevirtualnoexcept |
Flattened element count per batch item (inChannels*H*W).
Implements Deep::Layer.
|
inlinenoexcept |
Returns the input feature-map width.
|
inlinenoexcept |
Returns the convolution kernel height.
|
inlinenoexcept |
Returns the convolution kernel width.
|
inlinenoexcept |
Returns the weight-decay (L2 regularization) coefficient.
|
inlinenoexcept |
Returns the learning rate used for weight updates.
|
inlinenoexcept |
Returns this layer's top-down prediction buffer.
|
inlinenoexcept |
Returns the number of output channels (0 for a terminal layer).
|
inlinenoexcept |
Returns the output feature-map height.
|
inlineoverridevirtualnoexcept |
Flattened element count of this layer's OUTGOING prediction (outChannels*outH*outW), 0 for a terminal layer.
Implements Deep::Layer.
|
inlinenoexcept |
Returns the output feature-map width.
|
inlinenoexcept |
Returns the learning rate used for precision updates.
|
inlinenoexcept |
Returns this layer's precision buffer.
|
noexcept |
Computes the total number of floats this layer requires from a MemoryArena (weights, biases, beliefs, errors, and every scratch buffer combined).
|
overridevirtual |
Returns a dictionary of this.
Reimplemented from Deep::Layer.
|
inlinenoexcept |
Returns this layer's weight buffer.
|
inlinenoexcept |
Returns this layer's weight buffer.
|
noexcept |
Randomizes this layer's weights (and biases) in place.
| twister | The classic Mersenne Twister |
|
noexcept |
Resets this layer's beliefs/errors back to their initial values, without touching learned weights.
|
noexcept |
Rebuilds log_p from p – required after a checkpoint load that only persists p (mirrors DiscriminativePCLayer's fix for the same p/log_p desync issue found in ModelIO::Load()).
|
inlinenoexcept |
Sets the learning rate used for internal-state updates.
| ir | The new inference rate. |
|
inlinenoexcept |
Sets the weight-decay (L2 regularization) coefficient.
| l | The new lambda value. |
|
inlinenoexcept |
Sets the layer immediately above this one in the network.
| above | Pointer to the layer above; may be nullptr for a terminal layer. |
|
inlinenoexcept |
Sets the layer immediately below this one in the network.
| below | Pointer to the layer below; may be nullptr for the input layer. |
|
inlinenoexcept |
Sets the learning rate used for weight updates.
| lr | The new learning rate. |
|
inlinenoexcept |
Sets the learning rate used for precision updates.
| pr | The new precision rate. |
|
noexcept |
Releases a previous ClampState() call, allowing this layer's beliefs to update normally again.
|
noexcept |
Updates this layer's precision estimate from current prediction errors, using the configured precision rate (pr).
|
overridevirtualnoexcept |
Update latent beliefs (z/r) via inference gradient.
Implements Deep::Layer.
|
overridevirtualnoexcept |
Hebbian/gradient weight update.
Implements Deep::Layer.
|
friend |