pyhgf.updates.vectorised.categorical.vectorised_categorical_prediction_error#
- pyhgf.updates.vectorised.categorical.vectorised_categorical_prediction_error(layer)[source]#
Compute the prediction error of a categorical state node layer.
The value prediction error is the raw residual between the clamped observation (a one-hot pattern) and the softmax prediction:
\[\delta = \mu - \hat{\mu} = \mathrm{one\_hot} - \mathrm{softmax}\]which is the cross-entropy gradient with respect to the logits. No scaling is needed (the binary layer, by contrast, divides by its Bernoulli variance). The posterior precision is set equal to the expected precision (both one), so the parent’s smoothing gain is exactly one and the routed message is the residual multiplied back through the weights. Categorical leaves carry no volatility level: the volatility fields are left untouched.
- Parameters:
layer (LayerState) – Current categorical layer state with
mean(the clamped one-hot observation) andexpected_meanset by the prediction step.- Returns:
Updated layer state with
value_prediction_errorandprecisionset.- Return type: