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

Convolutional Predictive Coding Network built from ConvPCLayer. More...

#include <ConvPCNetwork.h>

Public Member Functions

 ConvPCNetwork (int batchSize) noexcept
 Constructs an empty network; add layers via AddLayer(), then Compile() before use.
 ~ConvPCNetwork ()=default
 ConvPCNetwork (const ConvPCNetwork &)=delete
ConvPCNetwork & operator= (const ConvPCNetwork &)=delete
void AddLayer (int inChannels, int outChannels, int inHeight, int inWidth, int kernelH, int kernelW, int strideH=1, int strideW=1, int padH=0, int padW=0, float lr=1e-6f, float ir=0.1f, float pr=0.01f, float lmbda=1e-2f, ActivationType aType=ActivationType::RELU, ActivationType dType=ActivationType::dRELU)
 Adds a convolutional layer. Pass outChannels=0 to mark a terminal layer (no outgoing prediction).
void Compile ()
 Sums every layer's required float count into a single contiguous arena and binds each layer into it. Call after all AddLayer() calls, before RandomizeWeights().
void RandomizeWeights (std::mt19937 &rng) noexcept
 Initializes every layer's weights randomly.
void ResetState () noexcept
 Resets the beliefs (z) on every layer.
void Clamp (const std::vector< float > &input) noexcept
 Clamps the flattened, batched input to the first (input) layer.
float CalculateState () noexcept
 Computes and returns the network's total energy at the current state, without changing it.
void UpdateState () noexcept
 Runs one settling step on every layer.
void UpdateWeights () noexcept
 Applies weight updates to every layer.
void UpdatePrecision () noexcept
 Applies precision updates to every layer.
ConvPCLayer * GetTerminalLayer () noexcept
 Returns the last layer (outChannels==0, the terminal one).
const auto & GetLayers () const noexcept
 Returns every layer in the network, in the order they were added.
int GetBatchSize () const noexcept
 Returns the batch size given at construction.
float TrainStep (const std::vector< float > &x, const std::vector< float > &y, int inferenceSteps)
 Full train step: clamp input+target, settle for inferenceSteps, update weights once, return the final energy.
std::vector< float > Predict (const std::vector< float > &x, int inferenceSteps)
 Clamps input only, settles, and returns the terminal layer's settled beliefs (flattened, batched).
void ProjectForward () noexcept
 Seeds hidden layers from a genuine forward pass through current weights, instead of zero-init. Call after Clamp(), before the settling loop.
float TrainStepWithProjection (const std::vector< float > &x, const std::vector< float > &y, int inferenceSteps)
 Full train step with forward-projection init: clamp input, project forward, clamp target, settle, update weights, return the final energy.
std::vector< float > PredictWithProjection (const std::vector< float > &x, int inferenceSteps)
 Inference-only counterpart to TrainStepWithProjection(): clamp input, project forward, settle, read out the terminal layer's beliefs. No target clamp, no weight update.

Friends

class PCNDiagnostics

Detailed Description

Convolutional Predictive Coding Network built from ConvPCLayer.

Constructor & Destructor Documentation

◆ ConvPCNetwork() [1/2]

Deep::ConvPCNetwork::ConvPCNetwork ( int batchSize)
explicitnoexcept

Constructs an empty network; add layers via AddLayer(), then Compile() before use.

Parameters
batchSizeFixed batch size for every layer.

◆ ~ConvPCNetwork()

Deep::ConvPCNetwork::~ConvPCNetwork ( )
default

◆ ConvPCNetwork() [2/2]

Deep::ConvPCNetwork::ConvPCNetwork ( const ConvPCNetwork & )
delete

Member Function Documentation

◆ AddLayer()

void Deep::ConvPCNetwork::AddLayer ( int inChannels,
int outChannels,
int inHeight,
int inWidth,
int kernelH,
int kernelW,
int strideH = 1,
int strideW = 1,
int padH = 0,
int padW = 0,
float lr = 1e-6f,
float ir = 0.1f,
float pr = 0.01f,
float lmbda = 1e-2f,
ActivationType aType = ActivationType::RELU,
ActivationType dType = ActivationType::dRELU )

Adds a convolutional layer. Pass outChannels=0 to mark a terminal layer (no outgoing prediction).

◆ CalculateState()

float Deep::ConvPCNetwork::CalculateState ( )
noexcept

Computes and returns the network's total energy at the current state, without changing it.

◆ Clamp()

void Deep::ConvPCNetwork::Clamp ( const std::vector< float > & input)
noexcept

Clamps the flattened, batched input to the first (input) layer.

◆ Compile()

void Deep::ConvPCNetwork::Compile ( )

Sums every layer's required float count into a single contiguous arena and binds each layer into it. Call after all AddLayer() calls, before RandomizeWeights().

◆ GetBatchSize()

int Deep::ConvPCNetwork::GetBatchSize ( ) const
inlinenoexcept

Returns the batch size given at construction.

◆ GetLayers()

const auto & Deep::ConvPCNetwork::GetLayers ( ) const
inlinenoexcept

Returns every layer in the network, in the order they were added.

◆ GetTerminalLayer()

ConvPCLayer * Deep::ConvPCNetwork::GetTerminalLayer ( )
inlinenoexcept

Returns the last layer (outChannels==0, the terminal one).

◆ operator=()

ConvPCNetwork & Deep::ConvPCNetwork::operator= ( const ConvPCNetwork & )
delete

◆ Predict()

std::vector< float > Deep::ConvPCNetwork::Predict ( const std::vector< float > & x,
int inferenceSteps )

Clamps input only, settles, and returns the terminal layer's settled beliefs (flattened, batched).

◆ PredictWithProjection()

std::vector< float > Deep::ConvPCNetwork::PredictWithProjection ( const std::vector< float > & x,
int inferenceSteps )

Inference-only counterpart to TrainStepWithProjection(): clamp input, project forward, settle, read out the terminal layer's beliefs. No target clamp, no weight update.

◆ ProjectForward()

void Deep::ConvPCNetwork::ProjectForward ( )
noexcept

Seeds hidden layers from a genuine forward pass through current weights, instead of zero-init. Call after Clamp(), before the settling loop.

◆ RandomizeWeights()

void Deep::ConvPCNetwork::RandomizeWeights ( std::mt19937 & rng)
noexcept

Initializes every layer's weights randomly.

◆ ResetState()

void Deep::ConvPCNetwork::ResetState ( )
noexcept

Resets the beliefs (z) on every layer.

◆ TrainStep()

float Deep::ConvPCNetwork::TrainStep ( const std::vector< float > & x,
const std::vector< float > & y,
int inferenceSteps )

Full train step: clamp input+target, settle for inferenceSteps, update weights once, return the final energy.

◆ TrainStepWithProjection()

float Deep::ConvPCNetwork::TrainStepWithProjection ( const std::vector< float > & x,
const std::vector< float > & y,
int inferenceSteps )

Full train step with forward-projection init: clamp input, project forward, clamp target, settle, update weights, return the final energy.

◆ UpdatePrecision()

void Deep::ConvPCNetwork::UpdatePrecision ( )
noexcept

Applies precision updates to every layer.

◆ UpdateState()

void Deep::ConvPCNetwork::UpdateState ( )
noexcept

Runs one settling step on every layer.

◆ UpdateWeights()

void Deep::ConvPCNetwork::UpdateWeights ( )
noexcept

Applies weight updates to every layer.

◆ PCNDiagnostics

friend class PCNDiagnostics
friend

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