![]() |
Deepity
Ultra-fast, SIMD-accelerated Predictive Coding
|
Convolutional Predictive Coding Network built from SimpleConvPCLayer – precision-free, AdamW-capable, device-aware. More...
#include <SimpleConvPCNetwork.h>
Public Member Functions | |
| SimpleConvPCNetwork (int batchSize, DeviceType device=DeviceType::DEVICE_CPU) noexcept | |
| Constructs an empty network; add layers via AddLayer(), then Compile() before use. | |
| SimpleConvPCNetwork (const SimpleConvPCNetwork &)=delete | |
| SimpleConvPCNetwork & | operator= (const SimpleConvPCNetwork &)=delete |
| ~SimpleConvPCNetwork ()=default | |
| 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 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), matching SimpleConvPCLayer's nextSize=0 convention. | |
| void | SetOptimizer (OptimizerType opt) noexcept |
| Sets the optimizer for EVERY layer added so far. Safe to call any time before Compile() – unlike using SimpleConvPCLayer standalone, memory allocation is deferred to Compile(), not the constructor, so this doesn't require a manual rebind. | |
| void | Compile () |
| Sums every layer's required float count into a single contiguous arena and binds each layer into it. Call after all AddLayer()/SetOptimizer() 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 |
| Calls UpdateWeights() on every layer except the terminal one (each layer's own UpdateWeights() is also self-guarded against outChannels==0, so this is belt-and-suspenders). | |
| SimpleConvPCLayer * | 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 |
Convolutional Predictive Coding Network built from SimpleConvPCLayer – precision-free, AdamW-capable, device-aware.
|
explicitnoexcept |
Constructs an empty network; add layers via AddLayer(), then Compile() before use.
| batchSize | Fixed batch size for every layer. |
| device | Which device this network's layers run on. |
|
delete |
|
default |
| void Deep::SimpleConvPCNetwork::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 | 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), matching SimpleConvPCLayer's nextSize=0 convention.
|
noexcept |
Computes and returns the network's total energy at the current state, without changing it.
|
noexcept |
Clamps the flattened, batched input to the first (input) layer.
| void Deep::SimpleConvPCNetwork::Compile | ( | ) |
Sums every layer's required float count into a single contiguous arena and binds each layer into it. Call after all AddLayer()/SetOptimizer() calls, before RandomizeWeights().
|
inlinenoexcept |
Returns the batch size given at construction.
|
inlinenoexcept |
Returns every layer in the network, in the order they were added.
|
inlinenoexcept |
Returns the last layer (outChannels==0, the terminal one).
|
delete |
| std::vector< float > Deep::SimpleConvPCNetwork::Predict | ( | const std::vector< float > & | x, |
| int | inferenceSteps ) |
Clamps input only, settles, and returns the terminal layer's settled beliefs (flattened, batched).
| std::vector< float > Deep::SimpleConvPCNetwork::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.
|
noexcept |
Seeds hidden layers from a genuine forward pass through current weights, instead of zero-init. Call after Clamp(), before the settling loop.
|
noexcept |
Initializes every layer's weights randomly.
|
noexcept |
Resets the beliefs (z) on every layer.
|
noexcept |
Sets the optimizer for EVERY layer added so far. Safe to call any time before Compile() – unlike using SimpleConvPCLayer standalone, memory allocation is deferred to Compile(), not the constructor, so this doesn't require a manual rebind.
| float Deep::SimpleConvPCNetwork::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.
| float Deep::SimpleConvPCNetwork::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.
|
noexcept |
Runs one settling step on every layer.
|
noexcept |
Calls UpdateWeights() on every layer except the terminal one (each layer's own UpdateWeights() is also self-guarded against outChannels==0, so this is belt-and-suspenders).
|
friend |