Neural-Network Layers#
braintrace.nn mirrors a subset of brainstate.nn, but routes each
layer’s trainable forward pass through ETP primitives. As a result, the layers
are drop-in replacements whose parameters automatically participate in online
learning — no manual wiring required.
For example, Linear uses braintrace.matmul() internally, so its
weight is included in eligibility-trace computation; GRUCell uses
braintrace.matmul() for its recurrent maps and braintrace.element_wise()
for gate operations.
Note
Activation, normalization, and pooling layers are intentionally not
re-implemented here. Accessing them through braintrace.nn (e.g.
braintrace.nn.LayerNorm) emits a DeprecationWarning and forwards
to brainstate.nn / brainstate.state; use those packages directly.
Linear Layers#
Linear transformation layer. |
|
Linear layer with signed absolute weights. |
|
Linear layer with sparse weight matrix. |
|
A standalone LoRA layer. |
Convolutional Layers#
Recurrent Layers#
Single-step recurrent cells. Each updates its hidden state in place and returns
the new hidden state (or, for LRUCell, the projected output).
Vanilla RNN cell. |
|
Gated Recurrent Unit (GRU) cell. |
|
Minimal Gated Recurrent Unit (MGU) cell. |
|
Long short-term memory (LSTM) RNN core. |
|
Update-Reset LSTM (URLSTM) cell. |
|
Minimal RNN Cell. |
|
Minimal GRU cell. |
|
Minimal LSTM cell. |
|
Linear Recurrent Unit (LRU) layer. |
Readout Layers#
Leaky dynamics for the read-out module used in Real-Time Recurrent Learning. |