pydeepity
Python bindings for Deepity
Loading...
Searching...
No Matches
deepity.GaussSeidelPCN.GaussSeidelPCN Class Reference
Inheritance diagram for deepity.GaussSeidelPCN.GaussSeidelPCN:

Public Member Functions

None __init__ (self, *Layer|Activation architecture, Optional[int] batch_size=None)
None configure (self, float learning_rate=1e-6, float inference_rate=0.1, float lmbda=1e-2, str optimizer="SGD")
None set_optimizer (self, str optimizer)
None set_learning_rate (self, float lr)
None set_inference_rate (self, float ir)
None compile (self)
None randomize_weights (self, Optional[int] seed=None, str dist="normal")
float train_step (self, npt.NDArray[np.float32] X, npt.NDArray[np.float32] Y, int steps)
float train_step_with_projection (self, npt.NDArray[np.float32] X, npt.NDArray[np.float32] Y, int steps)
npt.NDArray[np.float32] predict (self, npt.NDArray[np.float32] X, int steps)
"GaussSeidelPCN" fit (self, npt.NDArray[np.float32] X, npt.NDArray[np.float32] Y, int epochs, int steps, Optional[float] initial_lr=None, float decay_rate=1.0, bool shuffle=True)

Public Attributes

 architecture = architecture
 layers

Protected Member Functions

None _validate_architecture (self)
None _build_backend (self)
None _require_configured (self)

Protected Attributes

bool _configured = False
int _learning_rate = 1e-6
float _inference_rate = 0.1
int _lambda = 1e-2
str _optimizer = "SGD"

Detailed Description

A Predictive Coding Network with Gauss-Seidel (sequential-sweep)
settling dynamics.

Unlike the fully-synchronous (Jacobi) dynamics used by other PCN
implementations, Gauss-Seidel settling allows later layers to see
already-updated values from earlier layers within the same step.

A full settling step consists of three sweeps:

    1. Update z states.
    2. Recompute predictions using the fresh z states.
    3. Recompute errors using the fresh predictions.

Feedback goes through E, an independently-initialized, never-updated
feedback-alignment matrix (Lillicrap et al.), not W transposed, so
this is feedback alignment, not backprop-style symmetric weight
transport. The weight update itself (dE/dW) is a true gradient,
independently verified via finite-difference check
(tGaussSeidelPCLayerVerify.cpp). E's role in the state-settling
feedback term is deliberately not a gradient and isn't checked
against one, matching DirectKPPCN's own Psi.

Precision-free and AdamW-capable, matching SimplePCN's conventions.

Constructor & Destructor Documentation

◆ __init__()

None deepity.GaussSeidelPCN.GaussSeidelPCN.__init__ ( self,
*Layer | Activation architecture,
Optional[int] batch_size = None )

Member Function Documentation

◆ _build_backend()

None deepity.GaussSeidelPCN.GaussSeidelPCN._build_backend ( self)
protected
Translate the declarative architecture into backend PC layers.

Each Linear layer becomes a backend layer. If an Activation follows
it, that activation is attached to the backend layer.

◆ _require_configured()

None deepity.GaussSeidelPCN.GaussSeidelPCN._require_configured ( self)
protected

◆ _validate_architecture()

None deepity.GaussSeidelPCN.GaussSeidelPCN._validate_architecture ( self)
protected
Validate the declarative network architecture.

◆ compile()

None deepity.GaussSeidelPCN.GaussSeidelPCN.compile ( self)
Compile the backend network.

◆ configure()

None deepity.GaussSeidelPCN.GaussSeidelPCN.configure ( self,
float learning_rate = 1e-6,
float inference_rate = 0.1,
float lmbda = 1e-2,
str optimizer = "SGD" )
Configure the network and build its backend layers.

Parameters
----------
learning_rate:
    Weight-learning rate.

inference_rate:
    State-inference rate used during settling.

lmbda:
    Precision/regularization parameter for PC layers.

optimizer:
    Optimizer to use: SGD, ADAM, or ADAMW.

◆ fit()

"GaussSeidelPCN" deepity.GaussSeidelPCN.GaussSeidelPCN.fit ( self,
npt.NDArray[np.float32] X,
npt.NDArray[np.float32] Y,
int epochs,
int steps,
Optional[float] initial_lr = None,
float decay_rate = 1.0,
bool shuffle = True )
Run multi-epoch training with a live Rich progress display.

If initial_lr is omitted, the learning rate supplied to configure()
is used.

◆ predict()

npt.NDArray[np.float32] deepity.GaussSeidelPCN.GaussSeidelPCN.predict ( self,
npt.NDArray[np.float32] X,
int steps )
Settle the network and return the terminal-layer beliefs.

◆ randomize_weights()

None deepity.GaussSeidelPCN.GaussSeidelPCN.randomize_weights ( self,
Optional[int] seed = None,
str dist = "normal" )
Randomize all network weights. `seed` gives a reproducible run;
`dist` e.g. "normal(0,1)" or "uniform(-0.3,0.3)" (the default
"normal" has no "(a,b)" and so deliberately falls back to each
layer's own existing init).

◆ set_inference_rate()

None deepity.GaussSeidelPCN.GaussSeidelPCN.set_inference_rate ( self,
float ir )
Set the inference rate on every backend layer.

◆ set_learning_rate()

None deepity.GaussSeidelPCN.GaussSeidelPCN.set_learning_rate ( self,
float lr )
Set the learning rate on every backend layer.

◆ set_optimizer()

None deepity.GaussSeidelPCN.GaussSeidelPCN.set_optimizer ( self,
str optimizer )
Set the optimizer: SGD, ADAM, or ADAMW.

◆ train_step()

float deepity.GaussSeidelPCN.GaussSeidelPCN.train_step ( self,
npt.NDArray[np.float32] X,
npt.NDArray[np.float32] Y,
int steps )
Perform one training step using zero-initialized hidden states.

Hidden layers are reset for each batch and then settled using
Gauss-Seidel dynamics.

◆ train_step_with_projection()

float deepity.GaussSeidelPCN.GaussSeidelPCN.train_step_with_projection ( self,
npt.NDArray[np.float32] X,
npt.NDArray[np.float32] Y,
int steps )
Perform one training step using forward-projection initialization.

Hidden layers are initialized from a genuine forward pass through
the current weights before Gauss-Seidel settling.

Member Data Documentation

◆ _configured

bool deepity.GaussSeidelPCN.GaussSeidelPCN._configured = False
protected

◆ _inference_rate

float deepity.GaussSeidelPCN.GaussSeidelPCN._inference_rate = 0.1
protected

◆ _lambda

int deepity.GaussSeidelPCN.GaussSeidelPCN._lambda = 1e-2
protected

◆ _learning_rate

int deepity.GaussSeidelPCN.GaussSeidelPCN._learning_rate = 1e-6
protected

◆ _optimizer

deepity.GaussSeidelPCN.GaussSeidelPCN._optimizer = "SGD"
protected

◆ architecture

deepity.GaussSeidelPCN.GaussSeidelPCN.architecture = architecture

◆ layers

deepity.GaussSeidelPCN.GaussSeidelPCN.layers

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