Deepity
Ultra-fast, SIMD-accelerated Predictive Coding
Loading...
Searching...
No Matches
Deep::SimpleConvPCLayer Class Reference

Convolutional PC layer, precision-free, AdamW-capable, routed through IComputeBackend for GPU portability – see the file-level warning above for the GPU path's verification status. More...

#include <SimpleConvPCLayer.h>

Inheritance diagram for Deep::SimpleConvPCLayer:
Deep::Layer

Public Member Functions

 SimpleConvPCLayer (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 lmbda=1e-2f, ActivationType aType=ActivationType::RELU, ActivationType dType=ActivationType::dRELU, IComputeBackend *backend=nullptr)
float CalculateState () noexcept override
 Calculates the internal state of the layer.
void UpdateState () noexcept override
 Updates the states after calculation.
void UpdateWeights () noexcept override
 Updates the weights after state updates.
void Flush () noexcept override
 Flushes remaining batches.
void ClampState (const std::vector< float > &inputData) noexcept
 Clamps this layer's beliefs to inputData, fixing them against UpdateState() until UnclampState() is called.
void UnclampState () noexcept
 Releases a previous ClampState() call.
float * GetBeliefs () noexcept override
 Should return belief state z.
const float * GetErrors () const noexcept override
 Should return errors e.
size_t GetInputSize () const noexcept override
 Should return input size.
size_t GetOutputSize () const noexcept override
 Should return output size.
size_t GetBatchSize () const noexcept override
 Should return batch size.
const float * GetWeights () const noexcept
 Returns the weight tensor, shape [outChannels, inChannels*kernelH*kernelW].
float * GetWeights () noexcept
 Mutable overload of GetWeights() above.
const float * GetBiases () const noexcept
 Returns the bias vector, length outChannels.
float * GetBiases () noexcept
 Mutable overload of GetBiases() above.
float GetLearningRate () const noexcept
 Returns the current learning rate.
float GetInferenceRate () const noexcept
 Returns the current inference rate.
float GetLambda () const noexcept
 Returns the current weight decay coefficient.
void SetLearningRate (float lr) noexcept
 Sets the learning rate, propagating it to the optimizer state.
void SetInferenceRate (float ir) noexcept
 Sets the inference rate.
void SetLambda (float l) noexcept
 Sets the weight decay coefficient.
void SetOptimizer (const OptimizerType o) noexcept
 Sets the weight optimizer. Call BEFORE Compile().
bool IsClamped () const noexcept
 Whether ClampState() is currently active on this layer.
void SetLayerAbove (SimpleConvPCLayer *above) noexcept
 Sets the layer immediately above this one in the network.
void SetLayerBelow (SimpleConvPCLayer *below) noexcept
 Sets the layer immediately below this one in the network.
void ComputeMuOnly () noexcept
 Computes only mu (forward prediction), skipping error/energy.
void ResetState () noexcept
 Resets this layer's beliefs (z) without touching learned weights.
void RandomizeWeights (std::mt19937 &twister) noexcept
 Randomizes W/b.
ActivationType GetActivationType () const noexcept
 Returns this layer's activation type.
ActivationType GetDerivativeType () const noexcept
 Returns this layer's activation derivative type.
const float * GetMu () const noexcept
 Returns this layer's forward prediction buffer.
int GetInChannels () const noexcept
 Returns the input channel count.
int GetOutChannels () const noexcept
 Returns the output channel count (0 for a terminal layer).
int GetInHeight () const noexcept
 Returns the input height.
int GetInWidth () const noexcept
 Returns the input width.
int GetOutHeight () const noexcept
 Returns the output height.
int GetOutWidth () const noexcept
 Returns the output width.
int GetKernelH () const noexcept
 Returns the kernel height.
int GetKernelW () const noexcept
 Returns the kernel width.
size_t GetRequiredFloats () const noexcept
 Total floats this layer needs from its MemoryArena.
template<typename ArenaT>
void BindMemory (ArenaT &arena)
 Binds this layer's buffers into a pre-allocated arena (MemoryArena for CPU, DeviceMemoryArena for GPU).
Public Member Functions inherited from Deep::Layer
virtual ~Layer ()=default
virtual std::map< std::string, TensorDescriptor > GetStateDict () const
 Returns a dictionary of this.

Friends

class SimpleConvPCNDiagnostics

Additional Inherited Members

Protected Attributes inherited from Deep::Layer
size_t size
 Size of input.
size_t nextSize
 Size of output.

Detailed Description

Convolutional PC layer, precision-free, AdamW-capable, routed through IComputeBackend for GPU portability – see the file-level warning above for the GPU path's verification status.

Constructor & Destructor Documentation

◆ SimpleConvPCLayer()

Deep::SimpleConvPCLayer::SimpleConvPCLayer ( 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 lmbda = 1e-2f,
ActivationType aType = ActivationType::RELU,
ActivationType dType = ActivationType::dRELU,
IComputeBackend * backend = nullptr )
Parameters
inChannels,outChannelsInput/output channel counts.
inHeight,inWidthInput spatial dimensions.
kernelH,kernelWConvolution kernel size.
strideH,strideWConvolution stride.
padH,padWZero-padding on each spatial dimension.
batchSizeBatch size.
learningRateLearning rate for W/b.
inferenceRateInference rate (Euler integration step size).
lmbdaWeight decay (L2 regularization) coefficient.
aTypeActivation type.
dTypeActivation derivative type.
backendCompute backend to run on; defaults to a new CPUBackend if nullptr.

Member Function Documentation

◆ BindMemory()

template<typename ArenaT>
template void Deep::SimpleConvPCLayer::BindMemory< DeviceMemoryArena > ( ArenaT & arena)

Binds this layer's buffers into a pre-allocated arena (MemoryArena for CPU, DeviceMemoryArena for GPU).

Template Parameters
ArenaTEither MemoryArena or DeviceMemoryArena.

◆ CalculateState()

float Deep::SimpleConvPCLayer::CalculateState ( )
overridevirtualnoexcept

Calculates the internal state of the layer.

Returns
energy used

Implements Deep::Layer.

◆ ClampState()

void Deep::SimpleConvPCLayer::ClampState ( const std::vector< float > & inputData)
noexcept

Clamps this layer's beliefs to inputData, fixing them against UpdateState() until UnclampState() is called.

◆ ComputeMuOnly()

void Deep::SimpleConvPCLayer::ComputeMuOnly ( )
noexcept

Computes only mu (forward prediction), skipping error/energy.

◆ Flush()

void Deep::SimpleConvPCLayer::Flush ( )
inlineoverridevirtualnoexcept

Flushes remaining batches.

Reimplemented from Deep::Layer.

◆ GetActivationType()

ActivationType Deep::SimpleConvPCLayer::GetActivationType ( ) const
inlinenoexcept

Returns this layer's activation type.

◆ GetBatchSize()

size_t Deep::SimpleConvPCLayer::GetBatchSize ( ) const
inlineoverridevirtualnoexcept

Should return batch size.

Returns
? = 0

Implements Deep::Layer.

◆ GetBeliefs()

float * Deep::SimpleConvPCLayer::GetBeliefs ( )
inlineoverridevirtualnoexcept

Should return belief state z.

Returns
? = 0

Implements Deep::Layer.

◆ GetBiases() [1/2]

const float * Deep::SimpleConvPCLayer::GetBiases ( ) const
inlinenoexcept

Returns the bias vector, length outChannels.

◆ GetBiases() [2/2]

float * Deep::SimpleConvPCLayer::GetBiases ( )
inlinenoexcept

Mutable overload of GetBiases() above.

◆ GetDerivativeType()

ActivationType Deep::SimpleConvPCLayer::GetDerivativeType ( ) const
inlinenoexcept

Returns this layer's activation derivative type.

◆ GetErrors()

const float * Deep::SimpleConvPCLayer::GetErrors ( ) const
inlineoverridevirtualnoexcept

Should return errors e.

Returns
? = 0

Implements Deep::Layer.

◆ GetInChannels()

int Deep::SimpleConvPCLayer::GetInChannels ( ) const
inlinenoexcept

Returns the input channel count.

◆ GetInferenceRate()

float Deep::SimpleConvPCLayer::GetInferenceRate ( ) const
inlinenoexcept

Returns the current inference rate.

◆ GetInHeight()

int Deep::SimpleConvPCLayer::GetInHeight ( ) const
inlinenoexcept

Returns the input height.

◆ GetInputSize()

size_t Deep::SimpleConvPCLayer::GetInputSize ( ) const
inlineoverridevirtualnoexcept

Should return input size.

Returns
? = 0

Implements Deep::Layer.

◆ GetInWidth()

int Deep::SimpleConvPCLayer::GetInWidth ( ) const
inlinenoexcept

Returns the input width.

◆ GetKernelH()

int Deep::SimpleConvPCLayer::GetKernelH ( ) const
inlinenoexcept

Returns the kernel height.

◆ GetKernelW()

int Deep::SimpleConvPCLayer::GetKernelW ( ) const
inlinenoexcept

Returns the kernel width.

◆ GetLambda()

float Deep::SimpleConvPCLayer::GetLambda ( ) const
inlinenoexcept

Returns the current weight decay coefficient.

◆ GetLearningRate()

float Deep::SimpleConvPCLayer::GetLearningRate ( ) const
inlinenoexcept

Returns the current learning rate.

◆ GetMu()

const float * Deep::SimpleConvPCLayer::GetMu ( ) const
inlinenoexcept

Returns this layer's forward prediction buffer.

◆ GetOutChannels()

int Deep::SimpleConvPCLayer::GetOutChannels ( ) const
inlinenoexcept

Returns the output channel count (0 for a terminal layer).

◆ GetOutHeight()

int Deep::SimpleConvPCLayer::GetOutHeight ( ) const
inlinenoexcept

Returns the output height.

◆ GetOutputSize()

size_t Deep::SimpleConvPCLayer::GetOutputSize ( ) const
inlineoverridevirtualnoexcept

Should return output size.

Returns
? = 0

Implements Deep::Layer.

◆ GetOutWidth()

int Deep::SimpleConvPCLayer::GetOutWidth ( ) const
inlinenoexcept

Returns the output width.

◆ GetRequiredFloats()

size_t Deep::SimpleConvPCLayer::GetRequiredFloats ( ) const
noexcept

Total floats this layer needs from its MemoryArena.

◆ GetWeights() [1/2]

const float * Deep::SimpleConvPCLayer::GetWeights ( ) const
inlinenoexcept

Returns the weight tensor, shape [outChannels, inChannels*kernelH*kernelW].

◆ GetWeights() [2/2]

float * Deep::SimpleConvPCLayer::GetWeights ( )
inlinenoexcept

Mutable overload of GetWeights() above.

◆ IsClamped()

bool Deep::SimpleConvPCLayer::IsClamped ( ) const
inlinenoexcept

Whether ClampState() is currently active on this layer.

◆ RandomizeWeights()

void Deep::SimpleConvPCLayer::RandomizeWeights ( std::mt19937 & twister)
noexcept

Randomizes W/b.

◆ ResetState()

void Deep::SimpleConvPCLayer::ResetState ( )
noexcept

Resets this layer's beliefs (z) without touching learned weights.

◆ SetInferenceRate()

void Deep::SimpleConvPCLayer::SetInferenceRate ( float ir)
inlinenoexcept

Sets the inference rate.

◆ SetLambda()

void Deep::SimpleConvPCLayer::SetLambda ( float l)
inlinenoexcept

Sets the weight decay coefficient.

◆ SetLayerAbove()

void Deep::SimpleConvPCLayer::SetLayerAbove ( SimpleConvPCLayer * above)
inlinenoexcept

Sets the layer immediately above this one in the network.

◆ SetLayerBelow()

void Deep::SimpleConvPCLayer::SetLayerBelow ( SimpleConvPCLayer * below)
inlinenoexcept

Sets the layer immediately below this one in the network.

◆ SetLearningRate()

void Deep::SimpleConvPCLayer::SetLearningRate ( float lr)
noexcept

Sets the learning rate, propagating it to the optimizer state.

◆ SetOptimizer()

void Deep::SimpleConvPCLayer::SetOptimizer ( const OptimizerType o)
inlinenoexcept

Sets the weight optimizer. Call BEFORE Compile().

◆ UnclampState()

void Deep::SimpleConvPCLayer::UnclampState ( )
noexcept

Releases a previous ClampState() call.

◆ UpdateState()

void Deep::SimpleConvPCLayer::UpdateState ( )
overridevirtualnoexcept

Updates the states after calculation.

Implements Deep::Layer.

◆ UpdateWeights()

void Deep::SimpleConvPCLayer::UpdateWeights ( )
overridevirtualnoexcept

Updates the weights after state updates.

Implements Deep::Layer.

◆ SimpleConvPCNDiagnostics

friend class SimpleConvPCNDiagnostics
friend

The documentation for this class was generated from the following files: