Replay#

class hybrid_aif.Replay[source]#

Bases: NamedTuple

What replay() returns. Every leaf carries a leading (T, …) axis, one entry per tick.

Design: docs/design/zero-support-evidence.md Z2

beliefs: dict[str, Categorical | Gaussian | MixtureGaussian]#

The posteriors at every tick, keyed by state factor name.

priors: dict[str, Categorical | Gaussian | MixtureGaussian]#

The priors each posterior was inferred under, keyed by state factor name.

q_pi: Categorical#

The counterfactual policy posterior.

trees: dict[str, dict[str, Interval]] | None#

The term tree of q_pi (None under metrics=False).

chosen: dict[str, Array]#

The model’s own deterministic choice, keyed by the action nodes’ names (System.names.actions); under a policy module, the habit planner’s draw under key.

action_log_prob: Array | None#

log P(actions[t]) under the policy posterior, summed over the policies sharing that first step: -inf where no policy begins with it, the module’s log-density under a policy module, and None over a continuous action space with no module.

log_evidence: Array | None#

-free_energy: the tick’s log evidence where its posterior is exact (every modality linear-Gaussian, or one categorical state factor) and a lower bound otherwise, so its sum over the valid ticks is the prequential description length of the record under the model as it stood at each tick.

free_energy: Array | None#

The per-tick variational free energy (InferenceDetail.free_energy); None on the amortized path.

valid: Array#

Marks the real ticks.

exercised: dict[str, Array] | None#

Each modality mapped to a bool: present on at least one valid tick (None without present).

unsupported: dict[str, Array | None]#

Each state factor mapped to a (T,) bool (None for a continuous state factor; empty on the amortized path): under the beliefs held about its co-parents, no level was compatible with the tabular evidence. Co-parents of the contradicted state factor are flagged too.

params: SystemParams | None#

The final parameters (containers keyed by name) under learn=True, else None.

learn_state: LearnState | None#

The final optimizer carry under learn=True, else None.

emitted: dict[str, Array]#

Each emission realised from the tick’s posterior and recorded action, keyed by emission name; empty when the System declares no emissions or runs on the amortized path.

static __new__(
_cls,
beliefs,
priors,
q_pi,
trees,
chosen,
action_log_prob,
log_evidence,
free_energy,
valid,
exercised,
unsupported,
params,
learn_state,
emitted={},
)#

Create new instance of Replay(beliefs, priors, q_pi, trees, chosen, action_log_prob, log_evidence, free_energy, valid, exercised, unsupported, params, learn_state, emitted)