Welcome to Psychiatryai.com: Latest Evidence - RAISR4D

Estimated reading time for CME/CPD: 2 mins

pyhgf: A neural network library for predictive coding

AI Summary
  • pyhgf is a JAX and Rust backed Python library for building, manipulating, and sampling dynamic predictive coding networks with message passing.
  • Network components are transparent, modular, and malleable variables, enabling arbitrary belief propagation algorithms and biologically plausible self organisation and functional plasticity.
  • All core functions are differentiable and integrate seamlessly into sampling and optimisation workflows; includes Bayesian filtering and hierarchical Gaussian filter examples.
Summarise with AI (MRCPsych/FRANZCP)

PLoS Comput Biol. 2026 Jun 22;22(6):e1014340. doi: 10.1371/journal.pcbi.1014340. Online ahead of print.

ABSTRACT

Bayesian models of cognition have gained considerable traction in computational neuroscience and psychiatry. Their scopes are now expected to expand rapidly to artificial intelligence, providing general inference frameworks to support embodied, adaptable, and energy-efficient autonomous agents. A central theory in this domain is predictive coding, which posits that learning and behaviour are driven by hierarchical probabilistic inferences about the causes of sensory inputs. Biological realism constrains these networks to rely on simple local computations in the form of precision-weighted predictions and prediction errors. This can make this framework highly efficient, but its implementation comes with unique challenges on the software development side. Embedding such models in standard neural network libraries often becomes limiting, as these libraries’ compilation and differentiation backends can force a conceptual separation between optimization algorithms and the systems being optimized. This critically departs from other biological principles such as self-monitoring, self-organisation, cellular growth, and functional plasticity. In this paper, we introduce pyhgf: a Python package backed by JAX and Rust for creating, manipulating, and sampling dynamic networks for predictive coding. We improve over other frameworks by enclosing the network components as transparent, modular, and malleable variables in the message-passing steps. The resulting graphs can implement arbitrary algorithms as belief propagation. Moreover, the transparency of core variables can also translate into inference processes that leverage self-organisation principles and express structure learning, meta-learning, or causal discovery as the consequence of network structural adaptation to surprising inputs. The main functions of the library are differentiable and seamlessly integrate into sampling or optimization workflows. Additionally, we offer generalized Bayesian filtering and the hierarchical Gaussian filter as key examples of dynamic networks implemented in our library. The source code, tutorials, and documentation are hosted under the main repository at https://github.com/ComputationalPsychiatry/pyhgf.

PMID:42330057 | DOI:10.1371/journal.pcbi.1014340

Document this CPD

Share Evidence Blueprint

QR Code

Save to Google Notes

Search Google Scholar

Save as PDF

My Revision List

close chatgpt icon
ChatGPT

Enter your request.

← →
RAISR4D CME/CPD Evidence Nodes
Swipe to navigate RAISR4D CME/CPD evidence nodes.
CME/CPD