pydeepity
Python bindings for Deepity
Loading...
Searching...
No Matches
pydeepity

Python bindings for Deepity, a Predictive Coding (PC) neural network library. This page documents the deepity package (the pure-Python layer users actually import — distributed on PyPI as pydeepity), which wraps the compiled deepity extension module built from Deepity's C++ engine.

For the underlying C++ API, see the main Deepity documentation. For install/build instructions, see the GitHub README.

Quick Start

import numpy as np
import deepity as dy
net = dy.FullPCN(
dy.Linear(2, 32), dy.ReLU(),
dy.Linear(32, 1),
).configure(learning_rate=1e-3)
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]], dtype=np.float32)
Y = np.array([[0], [1], [1], [0]], dtype=np.float32)
for _ in range(1500):
net.train_step(X, Y, inference_steps=150)
print(net.predict(X, inference_steps=150))

More complete, runnable examples live in examples/ (e.g. examples/xor.py, examples/train_mnist_deep.py).

Networks

Each class wraps a templated C++ network and exposes a common configure() / train_step() / predict() / fit() surface:

Architecture Building Blocks

Passed positionally to a network's constructor to describe its architecture:

Backend Module

deepity._backend.dy is the raw compiled nanobind extension; everything in Networks and Architecture Building Blocks above wraps it. A handful of standalone utilities are re-exported directly, with no wrapper class: StreamAlignedBatcher, get_l2_cache_bytes, auto_batch_size, dynamic_thread, the omp_* thread-count queries, and the in-place SIMD activation functions (relu/drelu/tanh/dtanh/sigmoid/dsigmoid).

Elsewhere