spyx.experimental
Research-stage building blocks that are not part of the stable Spyx surface. Everything here is tested and usable, but the contract is different from the rest of the library.
Stability contract
The APIs in spyx.experimental — and in some cases their numerical
behaviour — may change without a deprecation cycle as the underlying
research matures. Anything you depend on for production or a long-lived
experiment should come from the stable top-level modules
(spyx.nn, spyx.ssm, spyx.phasor,
spyx.nir, spyx.bench, spyx.quant,
spyx.data, spyx.optimize).
The rule of thumb: import experimental things from spyx.experimental so
the dependency is explicit; rely on the top-level modules for stable work.
See Research with Spyx for how things graduate
from here into the core.
What's here
| Symbol | Kind | Notes |
|---|---|---|
spyx.experimental.PSU_LIF |
Neuron | Reset-free parallel LIF. Physically defined in spyx.nn, surfaced here as its supported experimental entry point. |
spyx.experimental.ResonateFire |
Neuron | Complex resonate-and-fire oscillatory neuron. Physically defined in spyx.phasor. |
spyx.experimental.raven |
Module | Routing-slot memory (RavenRSM), spiking sibling (SpikingSlotMemory), SlotRouter, and the make_recall_batch MQAR generator. |
spyx.experimental.compress |
Module | Bit-packed activation storage for memory-efficient BPTT. |
spyx.experimental.stochastic |
Module | Stochastic (Bernoulli-spiking) and parallelizable prototypes: SPSN, StochasticAssociative{LIF,CuBaLIF}, and the sigmoid_bernoulli activations. |
Related research studies live under
research/new/ in the
repository.
Re-exported neurons
These two are physically defined in stable modules and re-exported here so the experimental surface is discoverable in one place.
Bases: Module
Parallel Spiking Unit LIF: a reset-free leaky integrate-and-fire neuron.
.. note::
Experimental. Its supported entry point is
:class:spyx.experimental.PSU_LIF; the API may change without a
deprecation cycle. It is defined here for locality with the other neurons.
A standard :class:LIF subtracts a reset spikes * threshold from the
membrane every step, which couples each timestep to the (nonlinear) spike
of the previous step and forces a strictly sequential O(T) scan.
Dropping the reset turns the membrane into a pure linear leaky integrator,
.. math:: V_t = \beta \, V_{t-1} + x_t ,
which is a first-order associative recurrence and can therefore be
evaluated with :func:jax.lax.associative_scan in O(\log T) parallel
depth on an accelerator. Spikes are a pointwise surrogate threshold applied
to the whole membrane trace, :math:s_t = \sigma(V_t - \text{threshold}).
Removing the reset is a deliberate accuracy/parallelism trade-off: the neuron never depresses after firing, so it can fire on consecutive steps while a well-tuned integration window keeps activity bounded. In exchange the sequence can be scored in logarithmic instead of linear depth.
Two execution modes are provided and are numerically identical:
- :meth:
__call__-- one reset-free timestep(x, V) -> (spikes, V)withV = beta * V + x; a drop-in for :func:spyx.nn.run, :class:Sequential, and NIR, exactly like :class:LIF. - :meth:
parallel-- the whole time-major sequence at once via an associative scan over the leak,O(\log T)depth.
Because both modes use the same clipped beta and the same surrogate,
and :meth:__call__ integrates the input before spiking, scanning
:meth:__call__ over x reproduces :meth:parallel exactly.
Source code in spyx/nn.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
__call__(x, V)
One reset-free timestep.
input vector coming from previous layer.
:V: neuron state tensor.
Integrates the input into the membrane (V = beta * V + x, no
reset), then emits a surrogate spike on the updated membrane so that
scanning this method matches :meth:parallel exactly.
Source code in spyx/nn.py
__init__(hidden_shape, beta=None, threshold=1.0, activation=None, *, rngs)
:hidden_shape: Shape of the layer. :beta: decay rate. Scalar if provided, else learnable per-unit init. :threshold: firing threshold. Defaults to 1. :activation: spyx.axn.Axon object determining the surrogate spike.
Source code in spyx/nn.py
parallel(x)
Score a whole time-major sequence with an associative scan.
input with shape
[Time, Batch, ...].
:return: spikes with shape [Time, Batch, ...].
Computes the full membrane trace V_t = beta * V_{t-1} + x_t (with
V_{-1} = 0) via :func:jax.lax.associative_scan over the time axis
in O(\log T) depth, then applies the surrogate spike pointwise.
Source code in spyx/nn.py
Bases: Module
Resonate-and-fire neuron: the complex/oscillatory sibling of PSU_LIF.
.. note::
Experimental. Its supported entry point is
:class:spyx.experimental.ResonateFire; the API may change without a
deprecation cycle. It is defined here for locality with the phasor layers.
A resonate-and-fire neuron carries a complex membrane that behaves as a damped harmonic oscillator. Written reset-free, its subthreshold dynamics are a complex linear recurrence
.. math:: z_t = a \, z_{t-1} + x_t , \qquad a = e^{\,\mathrm{dt}\,(-\lambda + i\,\omega)} ,
with per-unit decay :math:\lambda \ge 0 and angular frequency
:math:\omega. The real input current x_t is injected into the real
part of the membrane. Because there is no reset, the recurrence stays
linear, so exactly like :class:spyx.nn.PSU_LIF it can be evaluated with
:func:jax.lax.associative_scan in :math:O(\log T) parallel depth -- only
now the scan runs over a complex pole a instead of a real leak.
Spikes are emitted by a pointwise surrogate threshold on the real part of
the oscillator, :math:s_t = \sigma(\Re(z_t) - \text{threshold}). The rule
is reset-free so the linear recurrence -- and therefore the parallel scan --
is preserved.
Stability: the pole magnitude is |a| = exp(-dt * lambda). Storing the
decay through a softplus keeps :math:\lambda \ge 0, hence
:math:|a| \le 1 and the oscillation never grows.
Parameters that enter the complex pole (lambda, omega) are stored as
real float32 nnx.Param tensors, mirroring :class:PhasorLinear:
the complex structure appears only in the forward pass, so a stock
optax + jax.grad loop over a real loss trains them without the
Wirtinger-conjugate surprise.
Two execution modes are provided and are numerically identical:
- :meth:
__call__-- one reset-free timestep(x, z) -> (spikes, z)withz = a * z + x; a drop-in for :func:spyx.nn.run/ :class:Sequential. - :meth:
parallel-- the whole time-major sequence at once via an associative scan over the complex pole, :math:O(\log T)depth.
Because both modes use the same pole and surrogate and integrate the input
before spiking, scanning :meth:__call__ over x reproduces
:meth:parallel exactly.
Source code in spyx/phasor.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
a
property
Complex oscillator pole a = exp(dt(-lambda + i*omega)).
The magnitude |a| = exp(-dt * lambda) <= 1 guarantees stability.
decay
property
Effective non-negative decay lambda = softplus(raw_lambda).
__call__(x, z)
One reset-free timestep.
real input current from the previous layer, broadcastable to
z.
:z: complex64 membrane state.
Injects x into the real part of the membrane and advances the
complex recurrence z = a * z + x (no reset), then emits a surrogate
spike on Re(z) so that scanning this method matches :meth:parallel.
Source code in spyx/phasor.py
__init__(hidden_shape, lambda_init=None, omega_init=None, threshold=1.0, dt=1.0, activation=None, *, rngs)
:hidden_shape: Per-unit shape of the layer.
:lambda_init: Membrane decay >= 0. Scalar constant if provided, else
a learnable per-unit initialisation. Stored through softplus so
the effective decay is always non-negative.
:omega_init: Angular frequency of the oscillator. Scalar constant if
provided, else a learnable per-unit initialisation.
:threshold: Real firing threshold on Re(z). Defaults to 1.
:dt: Integration timestep entering the pole exp(dt(-lambda+i*omega)).
:activation: :class:spyx.axn.Axon surrogate spike; defaults to
superspike.
Source code in spyx/phasor.py
initial_state(batch_size)
parallel(x)
Score a whole time-major sequence with an associative scan.
real input with shape
[Time, Batch, ...].
:return: spikes with shape [Time, Batch, ...].
Computes the full complex membrane trace z_t = a * z_{t-1} + x_t
(with z_{-1} = 0) via :func:jax.lax.associative_scan over the time
axis in :math:O(\log T) depth, then applies the surrogate spike
pointwise on Re(z).
Source code in spyx/phasor.py
spyx.experimental.raven
Raven Routing-Slot-Memory (RSM) block for Spyx.
A Flax NNX implementation of the Routing Slot Memory recurrence introduced by Raven (Afzal, Bick, Xing, Cevher, Gu, 2026; "High-recall sequence modeling with sparse memory routing"). Compressed-state recurrent models (a single SSM state with uniform decay) struggle with exact recall: every new token perturbs the whole state, so previously written associations interfere with each other.
Raven's fix is to partition the memory into M independent slots and use a
learned sparse router r_t to write only the selected slots, leaving the
rest untouched (shielded from interference). Writing slot m at step t:
.. math:: S_t = (1 - r_t) \odot S_{t-1} + r_t \odot ( D_t S_{t-1} A_t + U_t )
S_t: slot memory, shape(B, M, d_slot).r_t \in [0, 1]^M: the per-slot router (ideally sparse). Unselected slots (r_t[m] ≈ 0) pass through unchanged; selected slots decay and are written.U_t: the write (a projection of the current input).
The router is "a Mixture-of-Experts for memory". Two reductions are worth remembering (and are exercised by the tests):
- a dense router (
r_tall-ones) recovers a standard gated diagonal SSM, - a one-hot cyclic router recovers sliding-window attention.
Faithful-but-tractable simplification (documented, see
:class:RavenRSM): the per-slot transition is made diagonal — the full
matrix sandwich D_t S_{t-1} A_t is replaced by a per-slot (per-dim) decay
a ⊙ S_{t-1}, so each slot is a gated diagonal recurrence. The full
matrix-sandwich form is deferred. Likewise the recurrence is run with a plain
:func:jax.lax.scan reference (honest baseline); because the per-step transition
is input-dependent through the router gate (1 - r_t), the recurrence is a
per-timestep diagonal linear recurrence and an associative / chunked
associative_scan form is in principle possible (the Raven authors defer it to
a "Part 2"), but is not implemented here.
RavenRSM
Bases: Module
Routing-Slot-Memory recurrent block (diagonal simplification).
Sequence-in / sequence-out, matching the :mod:spyx.ssm interface:
__call__(u: (T, B, d_model)) -> (T, B, d_model).
Per step t the block computes, from u_t:
- a sparse write router
r_t = SlotRouter(u_t) \in [0, 1]^{(B, M)}, - the write
U_t = reshape(W_u u_t) \in (B, M, d_slot),
and updates the slot memory with the diagonal RSM recurrence
.. math:: S_t = (1 - r_t) \odot S_{t-1} + r_t \odot (a \odot S_{t-1} + U_t)
where a = sigmoid(raw_decay) \in (0, 1)^{(M, d_slot)} is a static,
learnable per-slot / per-dim decay (kept in (0, 1) for stability; an
input-dependent / selective decay is a straightforward extension but is not
used here so the dense reduction stays a clean gated diagonal SSM). The
recurrence is evaluated with :func:jax.lax.scan over time.
Readout (y_t): a query-gated read over slots. A learned query
q_t = softmax(W_q u_t) \in (B, M) mixes the slots into a single read
vector read_t = \sum_m q_t[m] S_t[m] \in (B, d_slot), which a linear map
projects back to (B, d_model). This mirrors the routing idea on the read
side: the query key selects which slot(s) to retrieve.
Simplifications (deferred, per the module docstring): (1) the full
matrix-sandwich transition D_t S_{t-1} A_t is replaced by the diagonal
decay a; (2) only a sequential lax.scan is provided — a chunked /
associative-scan form is possible but deferred.
Source code in spyx/experimental/raven.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
decay
property
Effective per-slot / per-dim decay a = sigmoid(raw_decay) in (0, 1).
__call__(u)
Apply the RSM block to a time-major input.
:u: real array of shape (T, B, d_model).
:return: real array of shape (T, B, d_model).
Source code in spyx/experimental/raven.py
initial_state(batch_size)
Return zero slot memory of shape (batch_size, M, d_slot).
step(state, u_t)
One reset-free RSM timestep.
:state: slot memory S_{t-1}, shape (B, M, d_slot).
:u_t: input (B, d_model).
:return: (S_t, y_t) with y_t of shape (B, d_model).
Source code in spyx/experimental/raven.py
SlotRouter
Bases: Module
Learned per-slot write gate r_t = sigmoid(W_r u_t).
A small, reusable submodule (the spiking Raven variant reuses it). Maps an
input of shape (..., d_model) to per-slot gates of shape (..., M) in
[0, 1]. With hard_top_k set, the gate is additionally sparsified to
the k most-active slots per row via a straight-through top-k (forward
is sparse, gradients stay dense); the default (None) is a soft gate.
Design choice: a per-input sigmoid (independent per-slot Bernoulli
logits) is used rather than a softmax so that several slots can be
written at once (a multi-write MoE-for-memory), and so the dense all-ones
reduction is reachable in the limit of large positive logits.
Source code in spyx/experimental/raven.py
__call__(u)
u: (..., d_model) -> gates (..., M) in [0, 1].
SpikingSlotMemory
Bases: Module
Spiking Routing-Slot Memory: a slot memory whose slots are spiking units.
This is the spiking sibling of :class:RavenRSM. It keeps the two ideas that
make Raven a high-recall memory -- a bank of M independent slots and
the same sparse write router -- but replaces each slot's linear
accumulator with the reset-free spiking membrane of
:class:spyx.nn.PSU_LIF: a leaky integrator V \leftarrow \beta V + x that
emits a surrogate spike s = \sigma(V - \text{threshold}). The result is
dual sparsity -- sparse in time (spikes) and sparse in slots
(routing).
The slot membrane V_t has shape (B, M, d_slot). Per step t, from
the input u_t:
- the write router
r_t = SlotRouter(u_t) \in [0, 1]^{(B, M)}(the exact router type reused from :class:RavenRSM--self.routeris a :class:SlotRouter, not a fork), and - the write
U_t = reshape(W_u u_t) \in (B, M, d_slot).
The membrane is then advanced with the routed, reset-free spiking recurrence
.. math:: V_t = (1 - r_t) \odot V_{t-1} + r_t \odot (\beta \odot V_{t-1} + U_t), \qquad s_t = \sigma(V_t - \text{threshold}),
where \beta = sigmoid(raw_beta) \in (0, 1)^{(M, d_slot)} is a static,
learnable per-slot / per-dim leak. Shielding: where r_t[m] = 0 the
update collapses to V_t[m] = V_{t-1}[m] -- the slot's membrane (and hence
its spike) is passed through byte-for-byte unchanged, shielded from
interference exactly as in :class:RavenRSM. Where r_t[m] = 1 the slot
runs a plain :class:spyx.nn.PSU_LIF step V \leftarrow \beta V + U_t.
Output is the raw slot spike train of shape (T, B, M, d_slot) (no
dense readout projection -- the block is a spiking memory; compose a linear
head downstream if real-valued outputs are needed).
Reset-freeness is deliberate: the membrane recurrence stays a first-order
linear map per slot, so -- exactly as documented for :class:spyx.nn.PSU_LIF
-- a chunked / :func:jax.lax.associative_scan parallel form is possible.
Because the per-step transition here is input-dependent through the router
gate (1 - r_t), the associative element is the affine map
V \mapsto A_t V + b_t with A_t = (1 - r_t) + r_t \beta and
b_t = r_t U_t; only the sequential :func:jax.lax.scan reference is
implemented here (an honest baseline), matching :class:RavenRSM.
Reductions (exercised by the tests): a dense router (r_t all-ones)
turns every slot into an independent, always-written
:class:spyx.nn.PSU_LIF -- i.e. a plain bank of spiking leaky integrators
driven by U_t; the routing is what makes it a memory.
Source code in spyx/experimental/raven.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
beta
property
Effective per-slot / per-dim leak beta = sigmoid(raw_beta) in (0, 1).
__call__(u)
Apply the spiking slot memory to a time-major input.
:u: real array of shape (T, B, d_model).
:return: spike train of shape (T, B, M, d_slot).
Source code in spyx/experimental/raven.py
__init__(d_model, n_slots=8, d_slot=None, *, hard_top_k=None, beta_init=0.9, threshold=1.0, activation=None, rngs)
:d_model: Input feature width.
:n_slots: Number of independent memory slots M.
:d_slot: Per-slot membrane width (defaults to d_model).
:hard_top_k: If set, the router keeps only its k most-active slots per
step (straight-through top-k); the default is a soft gate.
:beta_init: Initial per-slot leak in (0, 1) (stored as a logit).
:threshold: Firing threshold on the membrane.
:activation: :class:spyx.axn.Axon surrogate spike; defaults to
superspike (matching :class:spyx.nn.PSU_LIF).
:rngs: NNX PRNG collection.
Source code in spyx/experimental/raven.py
initial_state(batch_size)
Return zero slot membrane of shape (batch_size, M, d_slot).
step(state, u_t)
One reset-free spiking-slot timestep.
:state: slot membrane V_{t-1}, shape (B, M, d_slot).
:u_t: input (B, d_model).
:return: (V_t, s_t) -- the new membrane and the slot spikes of shape
(B, M, d_slot).
Source code in spyx/experimental/raven.py
make_recall_batch(key, *, batch=8, n_pairs=3, n_keys=8, n_values=8)
Generate a multi-query associative-recall (MQAR-style) batch.
Each example is a sequence of n_pairs (key, value) bindings followed
by a single query token equal to one of the presented keys. The target
is the value bound to the queried key — a task compressed-state SSMs fail at
but slot-routed memories solve, because each binding can live in its own
(interference-free) slot.
Tokens are one-hot encoded into d_model = n_keys + n_values dims: key
i -> e_i; value j -> e_{n_keys + j}. The query token reuses
its key's encoding. Sequence length is T = 2 * n_pairs + 1.
PRNG key.
:batch: number of independent examples.
:n_pairs: key/value bindings per example (distinct keys, sampled w/o repl.).
:n_keys: key vocabulary size (must be
>= n_pairs).
:n_values: value vocabulary size.
:return: (u, target) where u is (T, B, d_model) float one-hots
and target is (B,) int32 value ids for the query.
Source code in spyx/experimental/raven.py
spyx.experimental.compress
Bit-packed activation storage for memory-efficient BPTT.
Training spiking networks with backpropagation-through-time is dominated,
memory-wise, by the activations saved for the backward pass. In an SNN the
activations feeding each linear layer are the spikes, which are exactly
{0, 1} valued. A dense op spikes @ weight normally stashes the full
floating-point spikes tensor as its backward residual so it can later form
dW = spikes^T @ g. Storing one bit per spike as a float wastes 8x-32x the
memory it needs.
This module bit-packs that residual with :func:jax.numpy.packbits (8 spikes
per uint8) and unpacks it lazily inside the backward pass. The forward
output and both gradients (w.r.t. weight and spikes) are numerically
identical to the naive spikes @ weight -- we only trade a cheap
unpack-recompute for a large cut in the dominant activation residual.
Correctness relies on the input being exactly binary (values in {0, 1});
:func:packed_spike_dense is only valid for spike tensors, not arbitrary
floats.
pack_spikes(x, axis=-1)
Bit-pack a binary spike tensor along axis.
Mirrors the np.packbits(..., axis=...) convention used by
:mod:spyx.data (which packs along the time axis): every group of 8
consecutive {0, 1} values along axis is packed into a single
uint8, big-endian bit order. If the axis length is not a multiple of
8 the final byte is zero-padded on the low bits, so the original length
must be supplied to :func:unpack_spikes to recover the exact tensor.
:param x: binary tensor (values in {0, 1}); cast to uint8.
:param axis: axis along which to pack (default last).
:return: uint8 tensor with ceil(len/8) entries along axis.
Source code in spyx/experimental/compress.py
packed_spike_dense(spikes, weight)
spikes @ weight with a bit-packed backward residual.
Forward numerics are a plain matmul over the trailing feature axis of
spikes (shape (..., in)) against weight (shape (in, out)),
yielding (..., out). The custom VJP saves packbits(spikes) -- a
uint8 tensor 8x smaller than spikes would be as bf16/fp -- instead
of the dense activations, unpacking it in the backward pass to form
dW = spikes^T @ g and dspikes = g @ weight^T.
Both first-order gradients equal those of the naive spikes @ weight.
Limitations: valid only when spikes is exactly binary (values in
{0, 1}) -- packing a general float tensor silently binarizes the saved
residual, so the forward stays exact but dW becomes wrong. Only the
first-order VJP is correct; second-order derivatives (grad-of-grad) are not,
since the packed residual is not itself differentiated. Both are fine for
ordinary first-order BPTT, the intended use.
Source code in spyx/experimental/compress.py
unpack_spikes(packed, length, axis=-1)
Invert :func:pack_spikes, recovering length values along axis.
:param packed: uint8 tensor produced by :func:pack_spikes.
:param length: original (pre-pack) size of axis; trims the zero
padding introduced when length is not a multiple of 8.
:param axis: axis along which the tensor was packed (default last).
:return: uint8 tensor of {0, 1} values, length long on axis.
Source code in spyx/experimental/compress.py
spyx.experimental.stochastic
Experimental stochastic / parallelizable spiking-neuron prototypes.
Stochastic (Bernoulli-spiking) neurons and the SPSN prototype, all built on the
parallel prefix-scan (_pscan) membrane. Research-stage; the promoted,
production reset-free neuron is :class:spyx.experimental.PSU_LIF (in
spyx.nn). See [[SPSN]] (arXiv:2306.12666).
SPSN
Bases: Module
Prototype implementation of Stochastic Parallelizable Spiking Neuron:
https://doi.org/10.48550/arXiv.2306.12666
Source code in spyx/experimental/stochastic.py
beta = nnx.Param(nnx.initializers.truncated_normal(stddev=0.25)(rngs.params(), self.hidden_shape) + 0.5)
instance-attribute
hidden_shape = hidden_shape
instance-attribute
spike = sigmoid_bernoulli(k, threshold)
instance-attribute
threshold = threshold
instance-attribute
__call__(key, x)
Source code in spyx/experimental/stochastic.py
__init__(hidden_shape, threshold=1, k=10, *, rngs)
Source code in spyx/experimental/stochastic.py
StochasticAssociativeCuBaLIF
Bases: Module
Source code in spyx/experimental/stochastic.py
alpha = nnx.Param(nnx.initializers.truncated_normal(stddev=0.25)(rngs.params(), self.hidden_shape) + 0.5)
instance-attribute
beta = nnx.Param(nnx.initializers.truncated_normal(stddev=0.25)(rngs.params(), self.hidden_shape) + 0.5)
instance-attribute
hidden_shape = hidden_shape
instance-attribute
spike = refractory_sigmoid_bernoulli(k, threshold)
instance-attribute
__call__(key, u)
Source code in spyx/experimental/stochastic.py
__init__(hidden_shape, threshold=1, k=100, *, rngs)
Source code in spyx/experimental/stochastic.py
StochasticAssociativeLIF
Bases: Module