![]() |
Deepity
Ultra-fast, SIMD-accelerated Predictive Coding
|
An abstracted class for an array of DiscriminativePCLayer. More...
#include <DiscriminativePCNetwork.h>
Public Member Functions | |
| DiscriminativePCNetwork () | |
| Default constructor. | |
| DiscriminativePCNetwork (int batchSize) | |
| Batched constructor. | |
| ~DiscriminativePCNetwork ()=default | |
| Default constructor; deletes each layer. | |
| DiscriminativePCNetwork (DiscriminativePCNetwork &&other) noexcept=default | |
| Move constructor. | |
| DiscriminativePCNetwork & | operator= (DiscriminativePCNetwork &&other) noexcept=default |
| Move assignment operator. | |
| void | AddLayer (int size, int nextSize, float lr, float ir, float pr, 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 pr, float lmbda, Deep::ActivationType aType, Deep::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 | Clamp (const std::vector< float > &input) |
| Clamps the input to the first layer, necessary for prediction. | |
| float | CalculateState () |
| Calculates the state of each layer. | |
| void | UpdateState () |
| Updates each layer's state. | |
| void | UpdateWeights () |
| Updates each layer's weights. | |
| void | UpdatePrecision () |
| Updates each layer's precision weighting. | |
| void | ProjectForward () noexcept |
| Seeds every hidden layer's belief from a genuine forward pass through current weights, rather than zero-init. Assumes the input layer is already clamped. | |
| 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 > | PredictWithProjection (const std::vector< float > &x, int inferenceSteps) |
| Same as Predict(), but with ProjectForward() called once after clamping the input, before the settling loop. | |
| void | ResetState () noexcept |
| Resets each layer's state without touching learned weights. | |
| 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 for the network's layers. | |
| DiscriminativePCLayer * | GetTerminalLayer () const |
| Returns the network's terminal (final) layer. | |
| void | SetLearningRate (float lr) |
| Sets the learning rate used for weight updates, on every layer. | |
| void | SetInferenceRate (float ir) |
| Sets the inference rate used for state updates, on every layer. | |
| void | SetPrecisionRate (float pr) |
| Sets the learning rate used for precision updates, on every layer. | |
| void | SetLambda (float l) |
| Sets the weight-decay (L2 regularization) coefficient, on every layer. | |
| void | SetOptimizer (OptimizerType opt) noexcept |
| Sets the optimizer used for weight updates, on every layer. | |
| float | TrainStep (const std::vector< float > &x, const std::vector< float > &y, int inferenceSteps) |
| Runs a complete training step (clamp, settle, update, unclamp). | |
| std::vector< float > | Predict (const std::vector< float > &x, int inferenceSteps) |
| Runs a forward prediction pass (clamp, settle, read). | |
| bool | Save (const std::string &filename) const noexcept |
| Saves the network's learned parameters to disk. | |
| bool | Load (const std::string &filename) noexcept |
| Loads the network's learned parameters from disk. | |
| void | Compile () |
| Loads all layers into one contiguous block of memory. | |
Friends | |
| class | PCNDiagnostics |
An abstracted class for an array of DiscriminativePCLayer.
|
inline |
Default constructor.
Initializes the network with auto-batch size detection.
|
inline |
Batched constructor.
| batchSize | Batch size |
Initializes the network with a predetermined batch size.
|
default |
Default constructor; deletes each layer.
|
defaultnoexcept |
Move constructor.
| void Deep::DiscriminativePCNetwork::AddLayer | ( | int | size, |
| int | nextSize, | ||
| float | lr, | ||
| float | ir, | ||
| float | pr, | ||
| float | lmbda, | ||
| Deep::ActivationType | aType, | ||
| Deep::ActivationType | dType ) |
Adds a layer to the network, using a named ActivationType instead of raw function pointers.
| size | input size |
| nextSize | output size |
| lr | learning rate for beliefs |
| ir | learning rate for weights |
| pr | learning rate for precision |
| lmbda | weight decay (L2 regularization) coefficient |
| aType | activation type |
| dType | activation derivative type |
| void Deep::DiscriminativePCNetwork::AddLayer | ( | int | size, |
| int | nextSize, | ||
| float | lr, | ||
| float | ir, | ||
| float | pr, | ||
| float | lmbda, | ||
| void(* | act )(float *, size_t), | ||
| void(* | dAct )(float *, size_t, bool) ) |
Adds a layer to the network.
| size | input size |
| nextSize | output size |
| lr | learning rate for beliefs |
| ir | learning rate for weights |
| pr | learning rate for precision |
| lmbda | weight decay (L2 regularization) coefficient |
| act | activation function |
| dAct | derivative of previous activation function |
| float Deep::DiscriminativePCNetwork::CalculateState | ( | ) |
Calculates the state of each layer.
| void Deep::DiscriminativePCNetwork::Clamp | ( | const std::vector< float > & | input | ) |
Clamps the input to the first layer, necessary for prediction.
| input | reference to input vector |
| void Deep::DiscriminativePCNetwork::Compile | ( | ) |
Loads all layers into one contiguous block of memory.
|
inlinenoexcept |
Returns the batch size for the network's layers.
|
inlinenoexcept |
Returns every layer in the network, in the order they were added.
|
inline |
Returns the network's terminal (final) layer.
|
noexcept |
Loads the network's learned parameters from disk.
| filename | The source file path. |
|
defaultnoexcept |
Move assignment operator.
| std::vector< float > Deep::DiscriminativePCNetwork::Predict | ( | const std::vector< float > & | x, |
| int | inferenceSteps ) |
Runs a forward prediction pass (clamp, settle, read).
| x | The batched input data |
| inferenceSteps | The number of relaxation iterations |
| std::vector< float > Deep::DiscriminativePCNetwork::PredictWithProjection | ( | const std::vector< float > & | x, |
| int | inferenceSteps ) |
Same as Predict(), but with ProjectForward() called once after clamping the input, before the settling loop.
| x | The batched input data |
| inferenceSteps | The number of relaxation iterations |
|
noexcept |
Seeds every hidden layer's belief from a genuine forward pass through current weights, rather than zero-init. Assumes the input layer is already clamped.
| void Deep::DiscriminativePCNetwork::RandomizeWeights | ( | std::mt19937 & | rng | ) |
Randomizes the weights of each layer.
| rng | The classic Mersenne Twister |
|
noexcept |
Resets each layer's state without touching learned weights.
|
noexcept |
Saves the network's learned parameters to disk.
| filename | The destination file path. |
|
inline |
Sets the inference rate used for state updates, on every layer.
| ir | The new inference rate. |
|
inline |
Sets the weight-decay (L2 regularization) coefficient, on every layer.
| l | The new lambda value. |
|
inline |
Sets the learning rate used for weight updates, on every layer.
| lr | The new learning rate. |
|
inlinenoexcept |
Sets the optimizer used for weight updates, on every layer.
| opt | The optimizer type to apply. |
|
inline |
Sets the learning rate used for precision updates, on every layer.
| pr | The new precision rate. |
| float Deep::DiscriminativePCNetwork::TrainStep | ( | const std::vector< float > & | x, |
| const std::vector< float > & | y, | ||
| int | inferenceSteps ) |
Runs a complete training step (clamp, settle, update, unclamp).
| x | The batched input data |
| y | The batched target data |
| inferenceSteps | The number of relaxation iterations |
| float Deep::DiscriminativePCNetwork::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.
| x | The batched input data |
| y | The batched target data |
| inferenceSteps | The number of relaxation iterations |
| void Deep::DiscriminativePCNetwork::UpdatePrecision | ( | ) |
Updates each layer's precision weighting.
| void Deep::DiscriminativePCNetwork::UpdateState | ( | ) |
Updates each layer's state.
| void Deep::DiscriminativePCNetwork::UpdateWeights | ( | ) |
Updates each layer's weights.
|
friend |