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

Predictive Coding network built from GaussSeidelPCLayer, sweeping layers sequentially rather than updating them simultaneously. See the file-level warning above on its current verification status. More...

#include <GaussSeidelPCNetwork.h>

Public Member Functions

 GaussSeidelPCNetwork (int batchSize) noexcept
 Constructs an empty network with a predetermined batch size.
 ~GaussSeidelPCNetwork ()=default
 Default destructor.
 GaussSeidelPCNetwork (const GaussSeidelPCNetwork &)=delete
 Copy construction is disabled; a network owns its layers' memory arena and is not meant to be duplicated.
GaussSeidelPCNetwork & operator= (const GaussSeidelPCNetwork &)=delete
 Copy assignment is disabled; see the copy constructor.
void AddLayer (int size, int nextSize, float lr, float ir, float lmbda, void(*act)(float *, size_t), void(*dAct)(float *, size_t, bool))
 Adds a layer to the network.
void AddLayer (int size, int nextSize, float lr, float ir, float lmbda, ActivationType aType, ActivationType dType)
 Adds a layer to the network, using a named ActivationType instead of raw function pointers.
void RandomizeWeights (std::mt19937 &rng)
 Randomizes the weights of each layer.
void ResetState () noexcept
 Resets each layer's state without touching learned weights.
void Clamp (const std::vector< float > &input)
 Clamps the input to the first layer.
float Step () noexcept
 Runs ONE full Gauss-Seidel settling step (all three sweeps, in order) across every layer.
void UpdateWeights () noexcept
 Updates every non-terminal layer's weights. Called ONCE after the full settling loop completes, matching ngc-learn's evolve_process.
void ProjectForward () noexcept
 Seeds every hidden layer's z from a genuine forward pass through current weights (ComputePrediction() only, no error/energy side effects) – an orthogonal optimization to the Gauss-Seidel restructuring itself. Assumes layers[0] is already clamped.
void SetOptimizer (OptimizerType o) noexcept
 Sets the optimizer used for weight updates, on every layer.
void SetLearningRate (float lr) noexcept
 Sets the learning rate used for weight updates, on every layer.
GaussSeidelPCLayer * GetTerminalLayer () noexcept
 Returns the network's terminal (final) layer.
std::vector< std::unique_ptr< GaussSeidelPCLayer > > & GetLayers () noexcept
 Returns every layer in the network, in the order they were added.
const std::vector< std::unique_ptr< GaussSeidelPCLayer > > & GetLayers () const noexcept
 Returns every layer in the network, in the order they were added.
int GetBatchSize () const noexcept
 Returns the batch size for the network's layers.
float TrainStep (const std::vector< float > &x, const std::vector< float > &y, int inferenceSteps)
 Full train step: reset, clamp input+target, settle for inferenceSteps, update weights once, unclamp.
float TrainStepWithProjection (const std::vector< float > &x, const std::vector< float > &y, int inferenceSteps)
 Same as TrainStep(), but with ProjectForward() called once after clamping the input, before the settling loop.
std::vector< float > Predict (const std::vector< float > &x, int inferenceSteps)
 Forward prediction: clamp input, settle (no target clamped), read the terminal's beliefs.
void Compile ()
 Loads all layers into one contiguous block of memory.

Detailed Description

Predictive Coding network built from GaussSeidelPCLayer, sweeping layers sequentially rather than updating them simultaneously. See the file-level warning above on its current verification status.

Constructor & Destructor Documentation

◆ GaussSeidelPCNetwork() [1/2]

Deep::GaussSeidelPCNetwork::GaussSeidelPCNetwork ( int batchSize)
explicitnoexcept

Constructs an empty network with a predetermined batch size.

Parameters
batchSizeBatch size

◆ ~GaussSeidelPCNetwork()

Deep::GaussSeidelPCNetwork::~GaussSeidelPCNetwork ( )
default

Default destructor.

◆ GaussSeidelPCNetwork() [2/2]

Deep::GaussSeidelPCNetwork::GaussSeidelPCNetwork ( const GaussSeidelPCNetwork & )
delete

Copy construction is disabled; a network owns its layers' memory arena and is not meant to be duplicated.

Member Function Documentation

◆ AddLayer() [1/2]

void Deep::GaussSeidelPCNetwork::AddLayer ( int size,
int nextSize,
float lr,
float ir,
float lmbda,
ActivationType aType,
ActivationType dType )

Adds a layer to the network, using a named ActivationType instead of raw function pointers.

Parameters
sizeinput size
nextSizeoutput size
lrlearning rate for weight updates
irinference rate (Euler integration step size)
lmbdaweight decay (L2 regularization) coefficient
aTypeactivation type
dTypeactivation derivative type

◆ AddLayer() [2/2]

void Deep::GaussSeidelPCNetwork::AddLayer ( int size,
int nextSize,
float lr,
float ir,
float lmbda,
void(* act )(float *, size_t),
void(* dAct )(float *, size_t, bool) )

Adds a layer to the network.

Parameters
sizeinput size
nextSizeoutput size
lrlearning rate for weight updates
irinference rate (Euler integration step size)
lmbdaweight decay (L2 regularization) coefficient
actactivation function
dActderivative of previous activation function

◆ Clamp()

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

Clamps the input to the first layer.

Parameters
inputReference to the input vector.

◆ Compile()

void Deep::GaussSeidelPCNetwork::Compile ( )

Loads all layers into one contiguous block of memory.

◆ GetBatchSize()

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

Returns the batch size for the network's layers.

Returns
int batchSize

◆ GetLayers() [1/2]

const std::vector< std::unique_ptr< GaussSeidelPCLayer > > & Deep::GaussSeidelPCNetwork::GetLayers ( ) const
inlinenoexcept

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

Returns
A const reference to the internal layer list.

◆ GetLayers() [2/2]

std::vector< std::unique_ptr< GaussSeidelPCLayer > > & Deep::GaussSeidelPCNetwork::GetLayers ( )
inlinenoexcept

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

Returns
A reference to the internal layer list.

◆ GetTerminalLayer()

GaussSeidelPCLayer * Deep::GaussSeidelPCNetwork::GetTerminalLayer ( )
inlinenoexcept

Returns the network's terminal (final) layer.

Returns
Pointer to the last layer added via AddLayer().

◆ operator=()

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

Copy assignment is disabled; see the copy constructor.

◆ Predict()

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

Forward prediction: clamp input, settle (no target clamped), read the terminal's beliefs.

◆ ProjectForward()

void Deep::GaussSeidelPCNetwork::ProjectForward ( )
noexcept

Seeds every hidden layer's z from a genuine forward pass through current weights (ComputePrediction() only, no error/energy side effects) – an orthogonal optimization to the Gauss-Seidel restructuring itself. Assumes layers[0] is already clamped.

◆ RandomizeWeights()

void Deep::GaussSeidelPCNetwork::RandomizeWeights ( std::mt19937 & rng)

Randomizes the weights of each layer.

Parameters
rngThe classic Mersenne Twister

◆ ResetState()

void Deep::GaussSeidelPCNetwork::ResetState ( )
noexcept

Resets each layer's state without touching learned weights.

◆ SetLearningRate()

void Deep::GaussSeidelPCNetwork::SetLearningRate ( float lr)
inlinenoexcept

Sets the learning rate used for weight updates, on every layer.

Parameters
lrThe new learning rate.

◆ SetOptimizer()

void Deep::GaussSeidelPCNetwork::SetOptimizer ( OptimizerType o)
inlinenoexcept

Sets the optimizer used for weight updates, on every layer.

Parameters
oThe optimizer type to apply.

◆ Step()

float Deep::GaussSeidelPCNetwork::Step ( )
noexcept

Runs ONE full Gauss-Seidel settling step (all three sweeps, in order) across every layer.

Returns
Total energy, summed from every layer's ComputeError() – meaningful only after all three sweeps have run for this step.

◆ TrainStep()

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

Full train step: reset, clamp input+target, settle for inferenceSteps, update weights once, unclamp.

Returns
The final step's total energy, before weight updates.

◆ TrainStepWithProjection()

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

Same as TrainStep(), but with ProjectForward() called once after clamping the input, before the settling loop.

◆ UpdateWeights()

void Deep::GaussSeidelPCNetwork::UpdateWeights ( )
noexcept

Updates every non-terminal layer's weights. Called ONCE after the full settling loop completes, matching ngc-learn's evolve_process.


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