- Автор
- muellerberndt
- Размер
- 157.3 MB
- Звёзды
- 637
- Обновлён
- КоммитNov 16Релизv0.101.0Nov 16
- Возраст
- 2 мес
- Коммиты · 90 дней
README проекта с github.com/muellerberndt/cadence. Одним файлом markdown: README.md.
Live demos · Pragma Research · Documentation · Application demos · Paper · PyPI · Contact
One continuing equilibrium brain: learn a world, act in it, repair what fails.
Cadence is a Python library for brains that learn while they live. Animal and human brains learn from experience and not by backpropagation with gradient descent. Cadence is designed the same way: its connections change locally while the brain keeps running.
python -m pip install cadence-net==0.104.3
Python 3.11 or later and NumPy. "cadence-net[fast]==0.104.3" adds Numba and SciPy for speed
(recommended); [apple] adds MLX for Apple silicon GPUs and [accel] PyTorch for NVIDIA GPUs.
import numpy as np
from cadence import Brain
brain = Brain.compose(inputs=4, actions=2, arousal=True) # 4 senses, 2 possible actions
observation = np.array([[1.0, 0.0, 0.0, 0.0]]) # what it senses at this moment
action = brain.live(observation) # it settles and chooses an action
reward = (action == 0).astype(float) # your world scores that action
next_observation = np.array([[0.0, 1.0, 0.0, 0.0]])
action = brain.live(next_observation, reward=reward) # it learns from the score, acts again
The brain settles: its neurons drive each other until their activity comes to rest, the action is read from that state, and every synapse learns from the difference between two settles. There is no backward pass and no switch between training and use.
| Guide | What it gives you | |
|---|---|---|
| 1 | Start here: your first brain | the brain above, line by line: settling, lessons and rewards, the state it carries, saving |
| 2 | Assemble a brain | senses by name, a map of things, memories, attention, an ear and a voice, in four whole brains |
| 3 | Space: tracking what is where | a map that keeps things out of view and follows a hidden thing that moves |
| 4 | Sounds as symbols | a sound heard alone brings its thing back, a voice says it, a reward makes it the answer |
| Live demos | brains that see, move, play and keep learning, in the browser | |
| API reference | every public name, with its signature and refusals |
More guides: a continuing life, train a brain, learning from reward, memory, tune and read a living brain, backends; the documentation index lists them all. The released documentation describes the installed package. Integrated learned world prediction, repair localized to what failed and cheap stable operation are work in progress; Cadence is alpha research software.
Brain.compose builds one association region of 64 neurons between the senses and the motor
choice, and four memories: a working trace, a heard history, a recall memory and an associative
store (the default brain).
Under live the brain learns while young (its first 100 moments) or aroused by an outcome's
surprise or by want, and otherwise answers greedily from one settle; under step it learns from every outcome and from
teacher= labels. Everything else is opt-in
(assemble a brain).
live takes the preceding action's measured reward, then chooses the next
action for one continuing stream; supply one observation row per call. It needs
arousal=True (the founder arousal settings). The working trace advances at every
accepted moment, and so do the recall memory's slots. Tune named settings with compose or brain.retune(...)
and inspect them with brain.describe()
(tune and read).
Continuous interaction
covers arousal, resets and saved continuation.
For explicit teaching, batched streams or learning from every outcome, use the
lower-level step loop, which works with or without arousal=True; its
teacher= labels the current observation. The
continuing brain example
runs that loop through changed conditions and saved continuation.
A teacher label changes graph parameters. The default associative memory
ignores labels. Add memory_choice=True when remembered demonstrations and outcomes should
vote in the choice. Add learned_code=units, attention=True when the brain should retrieve a
relevant recent context and its successor, and recall_heads=k when one answer needs several
witnessed facts at once. The options can be used together.
Memory
starts with these common cases before giving the complete reference.
A brain trained without a recall memory gets one later: brain.grow(recall=True), or new output
slots with brain.grow(slots=...), returns a new brain, the trained one with the part added,
settling as the trained one did until learning gives the part weight. brain.graft(donor, ...) puts trained
regions of another brain into a larger one, such as a trained visual system, or a whole
connectome as one region of a larger anatomy
(grow and combine brains).
phases = brain.imagine([observation, next_observation])
assert phases # Inspect phase.qualified before using an imagined response.
Imagination carries a private trace without changing live memory, random state or pending feedback; the composed brain builds no model of the world's consequences.
Each action solve reports its residual, qualification, sweeps and check counts
in read-only brain.last_settlement, as
start a continuing brain
shows. An action whose settle exhausts its budget is refused without changing
live state; qualification and refusal
says when to retry live(observation) without resubmitting the reward.
To work from source, install the library repository root as an editable package:
python -m pip install -e .
recursive = Brain.compose(
inputs=4, actions=2, modules=(16, 8), observers=(8,), seed=7,
arousal=True,
)
Observer regions read and return influence to the base, motor regions and earlier observers. They join the same settlement and use the same interaction interface. Whether recursive feedback helps on a task is a question for experience and evaluation.
Brain.compose(inputs=4, actions=2, modules=(64, 32, 16)) builds reciprocal
regions whose activity settles together, so later regions shape earlier ones
while an answer forms, and the action comes from the qualified neural state.
The learner compares local activities in a free and a nudged phase, without a
backward differentiation pass. The relevant comparison with a recurrent
backprop network is acquired behavior and total work on the same task, as
the comparison below
sets out; the contracts
state what each part guarantees.
The library puts continuing state, reciprocal interpretation, local plasticity and memory behind one small interface. A saved brain resumes an action that awaits its actual outcome, and private imagination inspects responses without rewriting live experience. These are mechanisms for testing acquisition, retention and recovery through a life. Biological names describe functional software roles; one continuing equilibrium brain states the design direction.
The target includes full-sentence language and reusable world understanding; a small fixed-label task is a control.
This section maps Cadence onto models you know: which brain corresponds to which
familiar model, where each one's learning signal comes from, what the arrays look
like and what the words mean. The application interface is
Brain.compose(..., arousal=True), then brain.live(observation, reward=...) for
each real outcome (tune and read, start a continuing brain); the
families below are the numerical mechanisms underneath and beside it.
A Cadence brain is a set of patches joined by ports. A patch holds a bounded local state (the potentials of a group of neurons, or one context vector), reads its inputs through ports and updates by its declared equations. Graph models qualify a settled state and learn from detuned phases. The contract guide separates these cases.
| Cadence | Nearest familiar model | What is different |
|---|---|---|
Settling brain (Genome, develop, NeuralGraph, Learner) |
A continuous Hopfield or energy-based recurrent network trained by equilibrium propagation: rate neurons relax to a fixed point, and the gradient is the contrast of a free and a nudged fixed point. | Any wiring, including a measured connectome. Reciprocal learning ties paired weights; an arbitrary directed import need not satisfy the gradient contract. A certificate says when settling is a contraction and how far the answer is from the equilibrium. Reward learns through eligibility traces and one broadcast prediction error. |
The composed brain's memories key on the observation, on the fixed sparse code
code=units (the observation code),
or, opt-in, on a code the brain learns while it lives (learned_code=units,
the learned code),
both described under Code in the glossary. evolve mutates and selects genomes across lives
(evolution).
The opt-in Brain.compose(..., learned_code=units, attention=True) recipe uses that learned
code as a two-moment Recall address and holds one selected memory read through the shared
settle; with recall_heads=k it reads the same memories through k heads, each learning its
own address
(several heads).
No read revises its query during that settle
(memory guide).
beta
toward the target and a third nudged away give every synapse the
product of its two neurons in each phase; the difference over 2 beta is the
update. On a smooth stable equilibrium with symmetric effective weights the contrast
tends to the loss gradient as beta tends to zero
(learning). At a finite beta it is
an estimate with a beta^2 error term and a phase-solve term that grows as
1/beta; the default activation's kink at zero lies outside the smooth-branch
argument. benchmarks/local_equilibrium
compares the contrast learner with an implicit-gradient learner on the same network.| A network trained by backprop | A Cadence brain | |
|---|---|---|
| Reading an answer | Evaluate the layers | Settle to a fixed point with a residual check |
| State between inputs | A cache or a separate memory | A settled state, a carried context, a trace or a memory store, each explicit |
| Credit | Reverse-mode differentiation | Free and nudged contrasts for the settling brain; delta-rule writes for the memory stores |
| Exact-gradient conditions | A differentiable computation | For the contrast: a stable smooth equilibrium, symmetric effective weights, converged phases and a vanishing nudge |
| Work | A forward and a backward pass | Every step of the free and nudged phases plus the update |
| Memory of one event | A replay buffer or fine-tuning | One write into the store, read back at the same reading |
| Hardware | GPU tensors | NumPy float64 on the CPU, with Numba where installed; a new brain takes a CUDA (torch) or Apple (MLX) GPU in float32 where its size makes the device faster; in a web page under Pyodide, the same kernels in WebAssembly (backends) |
The table compares update mechanisms. Networks trained by backprop can also be recurrent, online, model-based and memory-using, so a fair comparison measures acquired behaviour and total work on the same task and information.
| Model | Inputs | Targets | State between calls | Checkpoint |
|---|---|---|---|---|
Composed Brain |
(batch, inputs) observations; one row for live |
step(teacher=...) labels the current observation; reward labels the preceding executed action |
Neural activity, working trace, optional efference copy, heard history, recall slots and their address map, the associative and episodic stores with the episodic temporal context, pending outcomes | Brain.save / Brain.load keep the complete continuation |
Neural graph / Learner |
a drive (batch, n), one column per neuron; features go on the input neurons |
integer labels (batch,) or (batch, slots) for Learner.step, or a target pattern (batch, n) for the phase calls |
BrainState per row; pass warm= to continue |
Learner.save / Learner.load, one .npz |
Batch rows are independent streams sharing parameters. imagine is private: it
changes no learned parameter, record or live activity, though cost counters may count
its work.
beta (default 0.1),
where smaller is closer to the gradient and weaker; the plus and minus beta phases are
contrasted over 2 beta.expansion units, of which
the winners strongest positive entries stay (code=units, PatternSeparator); the
sparse key of a store. The learned code (learned_code=units, LearnedCode) is a region
of the brain's own neurons that settles to a sparse code of the observation and learns it
by local rules while the brain lives; the cortex reads it, and every memory keys on it
joined to the observation's own identity.pre, post, count, sign)
and its named populations.NeuronModel.gain); the per-neuron scale of a neuron's
outgoing synapses, applied as exp(log_gain[pre]) and fixed by the learner; the
learned per-neuron offset.Measure settling, learning and memory maintenance separately on the same held-out data, and compare against the simple control the task admits: the majority outcome, persistence, a linear predictor, the search alone or the algorithmic solver. Evaluate a brain lists the checks and common missteps.
The paper states the hypotheses, the theorems and the evidence.
MANIFESTO.md states the design points, including the language goal of whole consistent sentences from the settled state. Your own anatomy covers custom wiring. cadence-demos contains the application demos.
Documentation · API · Contributing · Changelog · Research tasks
Licensed under GPL-3.0.
Observer Patch Holography (OPH) is the related physics project. Its physics evidence is separate from Cadence's capability evidence. Pragma Research brings the projects together.
Cadence has an official memecoin on Solana, deployed by the Solana community.
Its token address is 46doJPsSjEVMsNZm4b32UbbvbUXjFTM3TDPBWMM3pump
(chart on Dexscreener).
Its trading fees are routed to Bernhard Mueller to fund the project. Pragma
Research holds none of the token. Cadence itself does not use it, and no
integration into the core library is planned. We encourage the crypto community
to build interesting projects that integrate it. Any other token using the
Cadence name is unrelated to this project. Nothing here is financial advice.
Questions, collaboration and press: [email protected].