EligibilityTrace

EligibilityTrace#

class braintrace.EligibilityTrace#

Store the eligibility trace carried by an online-learning algorithm.

Parameters:
  • value (PyTree[ArrayLike]) – The initial eligibility-trace value.

  • name (str, optional) – The state name.

  • **metadata (Any) – Additional metadata stored with the state.

Examples

An eligibility trace wraps an array-valued state, just like any other brainstate.ShortTermState:

>>> import jax.numpy as jnp
>>> import braintrace
>>>
>>> trace = braintrace.EligibilityTrace(jnp.zeros((3, 4)))
>>> trace.value.shape
(3, 4)
EligibilityTrace.__init__(value, name=None, **metadata)#

Initialize a new HiddenState instance.

This constructor sets up the initial state for a hidden state in a dynamic model, handling various input types and metadata.

Parameters:
  • value (Union[PyTree[ArrayLike], StateMetadata[PyTree[ArrayLike]]]) – The initial value for the hidden state. Can be a PyTree of array-like objects or a StateMetadata object containing both value and metadata.

  • name (Optional[str], optional) – A name for the hidden state. Defaults to None.

  • **metadata – Additional metadata to be stored with the hidden state, including: - tag (Optional[str]): A tag for categorizing or grouping states. - Any other custom metadata fields.

Notes

This method initializes the hidden state, processes the input value and metadata, sets up internal attributes, and records the state initialization.