OTPE#

class braintrace.OTPE(model, mode='full', leak=None, name=None, vjp_method='single-step', trace_clip_abs=None, **kwargs)#

Online Training with Postsynaptic Estimates.

Parameters:
  • model (Module)

  • mode (str) – ‘full’ keeps the (batch, I, O) R_hat per layer. ‘approx’ factors R_hat as outer(ḡ_out, ẑ_in) for O(I+O) memory (F-OTPE variant); issues a UserWarning for depth > 1.

  • leak (float | None) – λ factor. If None, resolved via _resolve_leak.

  • trace_clip_abs (float | None) – Elementwise clip on R_hat each step. None disables.

  • name (str | None)

  • vjp_method (str)

compile_graph(*args)[source]#

Compile the eligibility trace graph of the relationship between etrace weights, states and operators.

The compilation process includes:

  • building the etrace graph

  • separating the states

  • initializing the etrace states

Parameters:

*args – The input arguments.

Return type:

None

init_etrace_state(*args, **kwargs)[source]#

Initialize the eligibility trace states of the etrace algorithm.

This method is needed after compiling the etrace graph. See .compile_graph() for the details.

Parameters:
  • *args – The positional arguments.

  • **kwargs – The keyword arguments.

Raises:

NotImplementedError – This method must be implemented by subclasses.

reset_state(batch_size=None, **kwargs)[source]#

State resetting function.