pyhgf.updates.vectorised.volatile.vectorised_layer_prediction#

pyhgf.updates.vectorised.volatile.vectorised_layer_prediction(child_state, parent_state, weights, params, time_step, coupling_fn=<PjitFunction of <function tanh>>, parent_has_constant=False, has_volatility_parent=True, is_input_layer=False, predict_precision=True, feedforward_uncertainty=False, mean_field_updates=False)[source]#

Predict expected mean/precision for all nodes in a volatile-node layer.

Computes both the value-level (external) and volatility-level (internal) predictions. Two predicted precisions of the value level are stored:

\[\hat{\pi}_a^{(k)} = \left( \frac{1}{\pi_a^{(k-1)}} + \Omega_a^{(k)} \right)^{-1}, \qquad \frac{1}{\tilde{\pi}_a^{(k)}} = \frac{1}{\hat{\pi}_a^{(k)}} + \sum_b \frac{ (t^{(k)} \, \alpha_b \, g'(\hat{\mu}_b))^2 } { \tilde{\pi}_b },\]

where \(\hat{\pi}_a\) (conditional_expected_precision) is the AR-plus-volatility chain precision without parent-uncertainty bleed-through and \(\tilde{\pi}_a\) (expected_precision) adds the first-order Laplace value-coupling contribution from each value parent. The bleed-through term uses the parent’s marginal predicted precision \(\tilde{\pi}_b\) (parent_state.expected_precision), which generalises the artefact’s two-node \(\hat{\pi}_b\) to deep networks by propagating each parent’s full marginal predictive variance. The volatility-coupling correction \(\kappa^2 / (2 \hat{\pi}_{\mathrm{vol}})\) enters \(\Omega_a^{(k)}\) inside the log-volatility exponent.

Parameters:
  • child_state (LayerState) – Current state of the child layer (being predicted).

  • parent_state (LayerState) – Current state of the parent layer (predictor).

  • weights (Array) – Weight matrix connecting child to parent, shape (n_children, n_parents) or (n_children, n_parents + 1) when the parent layer includes a constant input node.

  • params (LayerParams) – Layer parameters for the child layer.

  • time_step (float) – Time step \(t^{(k)}\) for the prediction.

  • coupling_fn (Callable) – Coupling function applied to parent means (default jax.numpy.tanh()).

  • parent_has_constant (bool) – If True, the parent layer has a constant input node (mean = 1.0) appended to its activations. The last column of weights carries the bias connections and is treated as linearly coupled (\(g(1) = 1\)), regardless of coupling_fn; the constant node’s derivative is zero and its predicted precision is infinite, so it contributes nothing to the value-coupling variance.

  • predict_precision (bool) – Whether the prediction step advances the precisions; see vectorised_layer_prediction().

  • has_volatility_parent (bool) – If True (default), the layer has an implied internal volatility parent whose state (mean_vol, precision_vol) is predicted and updated. If False, the value level’s only volatility source is its tonic volatility, when one is allocated; without one it does not undergo a Gaussian random walk at all: the diffusion term is dropped and the conditional predicted precision equals the prior precision.

  • feedforward_uncertainty (bool) – Whether the value parents propagate their uncertainty to this layer. With False (the default) they do not: the value-coupling variance is dropped, so the marginal and the conditional predicted precision coincide and the only uncertainty entering the layer is its own volatility parent’s. With True the parent’s uncertainty bleeds through as the law of total variance requires.

  • mean_field_updates (bool) – If True, the volatility level enters the log-volatility exponent at its expected mean alone — the MGF correction \(1 / (2 \hat{\pi}_{\mathrm{vol}})\) is dropped, matching the original mean-field prediction. Incompatible with feedforward_uncertainty (the mean-field scheme carries no value-coupling variance either); the network-level constructor enforces this.

  • predict_precision – Whether the prediction step advances the precisions at all. With False both predicted precisions are held at the layer’s prior precision, the effective precision is zero, and the volatility level is left untouched, so the only thing prediction produces is the expected mean. Precision then moves solely through the posterior update, if that is enabled. This is the same treatment is_input_layer gives an observed leaf, applied to every layer.

  • is_input_layer (bool) – If True, the layer is treated as an observed input/leaf: it does not undergo a Gaussian random walk between observations. The volatility contribution to the value-level expected precision is skipped, expected_precision and conditional_expected_precision are both set to the prior precision, and the effective precision is zeroed — mirroring the continuous-node treatment in pyhgf.updates.prediction.continuous.continuous_node_prediction().

Returns:

Updated child layer state with predicted means and precisions populated for both the value and volatility levels.

Return type:

LayerState