![]() |
pydeepity
Python bindings for Deepity
|
Public Member Functions | |
| None | __init__ (self, *Layer|Activation architecture, tuple[int, int, int] input_shape, int batch_size) |
| "ConvolutionalPCN" | configure (self, float learning_rate=1e-6, float inference_rate=0.1, float precision_rate=0.0, float lmbda=1e-2) |
| None | set_learning_rate (self, float learning_rate) |
| None | set_inference_rate (self, float inference_rate) |
| None | set_precision_rate (self, float precision_rate) |
| None | set_lambda (self, float lmbda) |
| None | compile (self) |
| None | randomize_weights (self, Optional[int] seed=None, str dist="normal") |
| None | clamp_input (self, npt.NDArray[np.float32] X) |
| None | project_forward (self) |
| None | update_precision (self) |
| 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) |
| npt.NDArray[np.float32] | predict_with_projection (self, npt.NDArray[np.float32] X, int steps) |
| "ConvolutionalPCN" | 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 | |
| input_shape = input_shape | |
| layers | |
Protected Member Functions | |
| None | _validate_architecture (self) |
| None | _build_backend (self) |
| None | _require_configured (self) |
Protected Attributes | |
| Optional[float] | _learning_rate = None |
| Optional[float] | _inference_rate = None |
| Optional[float] | _precision_rate = None |
| Optional[float] | _lambda = None |
Precision-weighted Convolutional Predictive Coding Network. The architecture is declared using Convolution and Activation objects (passed positionally, beginning with a Convolution), while `input_shape` and optimization/inference hyperparameters are supplied separately, see __init__() and configure().
| None deepity.ConvolutionalPCN.ConvolutionalPCN.__init__ | ( | self, | |
| *Layer | Activation | architecture, | ||
| tuple[int, int, int] | input_shape, | ||
| int | batch_size ) |
@param architecture Convolution/Activation objects describing the layer stack. @param input_shape (channels, height, width) of a single input image. @param batch_size Number of samples processed per train_step()/predict() call.
|
protected |
|
protected |
|
protected |
| None deepity.ConvolutionalPCN.ConvolutionalPCN.clamp_input | ( | self, | |
| npt.NDArray[np.float32] | X ) |
| None deepity.ConvolutionalPCN.ConvolutionalPCN.compile | ( | self | ) |
| "ConvolutionalPCN" deepity.ConvolutionalPCN.ConvolutionalPCN.configure | ( | self, | |
| float | learning_rate = 1e-6, | ||
| float | inference_rate = 0.1, | ||
| float | precision_rate = 0.0, | ||
| float | lmbda = 1e-2 ) |
Configure and build the convolutional network. Must be called once, before train_step()/predict(). @param learning_rate Learning rate for the forward weights. @param inference_rate Inference/settling rate. @param precision_rate Learning rate for precision weighting. @param lmbda Regularization parameter.
| "ConvolutionalPCN" deepity.ConvolutionalPCN.ConvolutionalPCN.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 ) |
Train for multiple epochs over (X, Y), batching by `self.batch_size` and printing a progress bar.
| npt.NDArray[np.float32] deepity.ConvolutionalPCN.ConvolutionalPCN.predict | ( | self, | |
| npt.NDArray[np.float32] | X, | ||
| int | steps ) |
Run inference on `X`, settling for `steps` iterations. @return The terminal layer's beliefs.
| npt.NDArray[np.float32] deepity.ConvolutionalPCN.ConvolutionalPCN.predict_with_projection | ( | self, | |
| npt.NDArray[np.float32] | X, | ||
| int | steps ) |
Same as predict(), but initializes every layer's beliefs via a forward projection pass first.
| None deepity.ConvolutionalPCN.ConvolutionalPCN.project_forward | ( | self | ) |
| None deepity.ConvolutionalPCN.ConvolutionalPCN.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).
| None deepity.ConvolutionalPCN.ConvolutionalPCN.set_inference_rate | ( | self, | |
| float | inference_rate ) |
Set the inference/settling rate on every layer.
| None deepity.ConvolutionalPCN.ConvolutionalPCN.set_lambda | ( | self, | |
| float | lmbda ) |
Set the regularization parameter on every layer.
| None deepity.ConvolutionalPCN.ConvolutionalPCN.set_learning_rate | ( | self, | |
| float | learning_rate ) |
Set the learning rate on every layer.
| None deepity.ConvolutionalPCN.ConvolutionalPCN.set_precision_rate | ( | self, | |
| float | precision_rate ) |
Set the precision-weighting learning rate on every layer.
| float deepity.ConvolutionalPCN.ConvolutionalPCN.train_step | ( | self, | |
| npt.NDArray[np.float32] | X, | ||
| npt.NDArray[np.float32] | Y, | ||
| int | steps ) |
Run one training step on a single batch, settling for `steps` iterations before updating weights. @return Total settling energy accumulated over `steps`.
| float deepity.ConvolutionalPCN.ConvolutionalPCN.train_step_with_projection | ( | self, | |
| npt.NDArray[np.float32] | X, | ||
| npt.NDArray[np.float32] | Y, | ||
| int | steps ) |
Same as train_step(), but initializes every layer's beliefs via a forward projection pass first instead of whatever state they held from the previous call.
| None deepity.ConvolutionalPCN.ConvolutionalPCN.update_precision | ( | self | ) |
|
protected |
|
protected |
|
protected |
|
protected |
| deepity.ConvolutionalPCN.ConvolutionalPCN.architecture = architecture |
| deepity.ConvolutionalPCN.ConvolutionalPCN.input_shape = input_shape |
| deepity.ConvolutionalPCN.ConvolutionalPCN.layers |