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

Public Member Functions

None __init__ (self, *Layer|Activation architecture, Optional[int] batch_size=None, str device="cpu")
"DKPPCN" configure (self, float learning_rate=1e-6, float inference_rate=0.1, float feedback_rate=1e-4, float lmbda=1e-2, str optimizer="SGD", str psi_optimizer="SGD")
None set_optimizer (self, str optimizer)
None set_psi_optimizer (self, str optimizer)
None set_learning_rate (self, float learning_rate)
None set_feedback_rate (self, float feedback_rate)
None set_inference_rate (self, float inference_rate)
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 inference_steps=1)
npt.NDArray[np.float32] predict (self, npt.NDArray[np.float32] X, int inference_steps=1)
"DKPPCN" fit (self, npt.NDArray[np.float32] X, npt.NDArray[np.float32] Y, int epochs, int inference_steps=1, Optional[float] initial_lr=None, float decay_rate=1.0, bool shuffle=True)

Public Attributes

 architecture = architecture
 device = device
 layers

Protected Member Functions

None _validate_architecture (self)
None _build_backend (self)
int _terminal_size (self)
None _require_configured (self)

Protected Attributes

Optional[float] _learning_rate = None
Optional[float] _inference_rate = None
Optional[float] _feedback_rate = None
Optional[float] _lambda = None
Optional[str] _optimizer = None
Optional[str] _psi_optimizer = None

Detailed Description

Predictive Coding Network using Direct Kolen-Pollack (DKP)
feedback alignment.

DKP maintains independently learned forward weights (W) and
direct feedback weights (Psi). The feedback pathway connects
hidden layers directly to the terminal error rather than
relaying errors layer-by-layer.

Unlike the other PCN implementations, DKP performs a direct
feedback alignment update before the ordinary settling loop.
This allows inference_steps=1 to be the default operating point.

Constructor & Destructor Documentation

◆ __init__()

None deepity.DKPPCN.DKPPCN.__init__ ( self,
*Layer | Activation architecture,
Optional[int] batch_size = None,
str device = "cpu" )

Member Function Documentation

◆ _build_backend()

None deepity.DKPPCN.DKPPCN._build_backend ( self)
protected

◆ _require_configured()

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

◆ _terminal_size()

int deepity.DKPPCN.DKPPCN._terminal_size ( self)
protected

◆ _validate_architecture()

None deepity.DKPPCN.DKPPCN._validate_architecture ( self)
protected

◆ compile()

None deepity.DKPPCN.DKPPCN.compile ( self)
Allocate backend buffers for the network built by
_build_backend(). Called automatically by configure().

◆ configure()

"DKPPCN" deepity.DKPPCN.DKPPCN.configure ( self,
float learning_rate = 1e-6,
float inference_rate = 0.1,
float feedback_rate = 1e-4,
float lmbda = 1e-2,
str optimizer = "SGD",
str psi_optimizer = "SGD" )
Configure and initialize the DKP network.

Parameters
----------
learning_rate:
    Learning rate for the forward weights W.

inference_rate:
    Inference/settling rate.

feedback_rate:
    Learning rate for the direct feedback weights Psi.

lmbda:
    Regularization parameter.

optimizer:
    Optimizer used for W.

psi_optimizer:
    Independent optimizer used for Psi.

◆ fit()

"DKPPCN" deepity.DKPPCN.DKPPCN.fit ( self,
npt.NDArray[np.float32] X,
npt.NDArray[np.float32] Y,
int epochs,
int inference_steps = 1,
Optional[float] initial_lr = None,
float decay_rate = 1.0,
bool shuffle = True )
Train the network for multiple epochs.

DKP defaults to one inference step because direct feedback
alignment is specifically intended to reduce the amount of
iterative settling required.

◆ predict()

npt.NDArray[np.float32] deepity.DKPPCN.DKPPCN.predict ( self,
npt.NDArray[np.float32] X,
int inference_steps = 1 )
Run inference on `X`, settling for `inference_steps` iterations.
@return The terminal layer's beliefs.

◆ randomize_weights()

None deepity.DKPPCN.DKPPCN.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_feedback_rate()

None deepity.DKPPCN.DKPPCN.set_feedback_rate ( self,
float feedback_rate )
Set the learning rate for the feedback weights Psi.

◆ set_inference_rate()

None deepity.DKPPCN.DKPPCN.set_inference_rate ( self,
float inference_rate )
Set the inference/settling rate.

◆ set_learning_rate()

None deepity.DKPPCN.DKPPCN.set_learning_rate ( self,
float learning_rate )
Set the learning rate for the forward weights W.

◆ set_optimizer()

None deepity.DKPPCN.DKPPCN.set_optimizer ( self,
str optimizer )
Set the optimizer used for the forward weights W.

◆ set_psi_optimizer()

None deepity.DKPPCN.DKPPCN.set_psi_optimizer ( self,
str optimizer )
Set the optimizer used for the feedback weights Psi.

◆ train_step()

float deepity.DKPPCN.DKPPCN.train_step ( self,
npt.NDArray[np.float32] X,
npt.NDArray[np.float32] Y,
int inference_steps = 1 )
Run one training step on a single batch: a direct feedback
alignment update, then settling for `inference_steps`
iterations before updating weights.
@return Total settling energy accumulated over `inference_steps`.

Member Data Documentation

◆ _feedback_rate

Optional[float] deepity.DKPPCN.DKPPCN._feedback_rate = None
protected

◆ _inference_rate

Optional[float] deepity.DKPPCN.DKPPCN._inference_rate = None
protected

◆ _lambda

Optional[float] deepity.DKPPCN.DKPPCN._lambda = None
protected

◆ _learning_rate

Optional[float] deepity.DKPPCN.DKPPCN._learning_rate = None
protected

◆ _optimizer

Optional[str] deepity.DKPPCN.DKPPCN._optimizer = None
protected

◆ _psi_optimizer

Optional[str] deepity.DKPPCN.DKPPCN._psi_optimizer = None
protected

◆ architecture

deepity.DKPPCN.DKPPCN.architecture = architecture

◆ device

deepity.DKPPCN.DKPPCN.device = device

◆ layers

deepity.DKPPCN.DKPPCN.layers

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