Academic Journal

pyhgf: A neural network library for predictive coding.

Λεπτομέρειες βιβλιογραφικής εγγραφής
Τίτλος: pyhgf: A neural network library for predictive coding.
Συγγραφείς: Legrand, Nicolas1 (AUTHOR) nicolas.legrand@cas.au.dk, Weber, Lilian2 (AUTHOR), Waade, Peter Thestrup1 (AUTHOR), Møller Daugaard, Anna Hedvig1 (AUTHOR), Khodadadi, Mojtaba3 (AUTHOR), Mikuš, Nace1 (AUTHOR), Mathys, Christoph1 (AUTHOR)
Πηγή: PLoS Computational Biology. 6/22/2026, Vol. 22 Issue 6, p1-18. 18p.
Θεματικοί όροι: *Software libraries (Computer programming), *Computational neuroscience, *Bayesian analysis, *Time-varying networks, *Neuromorphics, *Hierarchical Bayes model
Περίληψη: 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. Author summary: Many theories of brain function propose that perception and learning arise from Bayesian inference, in which the brain continuously updates beliefs about the causes of sensory inputs. One influential framework implementing this idea is predictive coding, where hierarchical networks exchange predictions and prediction errors to update internal beliefs. These models have been widely used to study learning, decision-making, and psychiatric conditions. However, applying predictive coding to complex models or large datasets remains difficult because existing tools are often specialized, inflexible, or poorly integrated with modern machine-learning and probabilistic programming frameworks. Here we introduce pyhgf, a software library for building and analysing dynamic predictive coding networks. The library implements the generalized hierarchical Gaussian filter, a model that represents how beliefs and their uncertainty evolve over time. In pyhgf, networks are composed of modular nodes that exchange predictions and prediction errors through local computations, making it possible to flexibly construct complex hierarchical models. The library is designed to integrate with modern computational tools, enabling efficient simulation, parameter estimation, and model comparison. By lowering the technical barriers to building predictive coding models, pyhgf provides a practical framework for studying adaptive behaviour and developing biologically inspired artificial agents. [ABSTRACT FROM AUTHOR]
Βάση Δεδομένων: Academic Search Index
FullText Text:
  Availability: 0
CustomLinks:
  – Url: https://resolver.ebsco.com/c/fiv2js/result?sid=EBSCO:asx&genre=article&issn=1553734X&ISBN=&volume=22&issue=6&date=20260622&spage=1&pages=1-18&title=PLoS Computational Biology&atitle=pyhgf%3A%20A%20neural%20network%20library%20for%20predictive%20coding.&aulast=Legrand%2C%20Nicolas&id=DOI:10.1371/journal.pcbi.1014340
    Name: Full Text Finder (for New FTF UI) (ns324271)
    Category: fullText
    Text: Full Text Finder
    MouseOverText: Full Text Finder
Header DbId: asx
DbLabel: Academic Search Index
An: 194756459
RelevancyScore: 1452
AccessLevel: 6
PubType: Academic Journal
PubTypeId: academicJournal
PreciseRelevancyScore: 1452.41955566406
IllustrationInfo
Items – Name: Title
  Label: Title
  Group: Ti
  Data: pyhgf: A neural network library for predictive coding.
– Name: Author
  Label: Authors
  Group: Au
  Data: <searchLink fieldCode="AR" term="%22Legrand%2C+Nicolas%22">Legrand, Nicolas</searchLink><relatesTo>1</relatesTo> (AUTHOR)<i> nicolas.legrand@cas.au.dk</i><br /><searchLink fieldCode="AR" term="%22Weber%2C+Lilian%22">Weber, Lilian</searchLink><relatesTo>2</relatesTo> (AUTHOR)<br /><searchLink fieldCode="AR" term="%22Waade%2C+Peter+Thestrup%22">Waade, Peter Thestrup</searchLink><relatesTo>1</relatesTo> (AUTHOR)<br /><searchLink fieldCode="AR" term="%22Møller+Daugaard%2C+Anna+Hedvig%22">Møller Daugaard, Anna Hedvig</searchLink><relatesTo>1</relatesTo> (AUTHOR)<br /><searchLink fieldCode="AR" term="%22Khodadadi%2C+Mojtaba%22">Khodadadi, Mojtaba</searchLink><relatesTo>3</relatesTo> (AUTHOR)<br /><searchLink fieldCode="AR" term="%22Mikuš%2C+Nace%22">Mikuš, Nace</searchLink><relatesTo>1</relatesTo> (AUTHOR)<br /><searchLink fieldCode="AR" term="%22Mathys%2C+Christoph%22">Mathys, Christoph</searchLink><relatesTo>1</relatesTo> (AUTHOR)
– Name: TitleSource
  Label: Source
  Group: Src
  Data: <searchLink fieldCode="JN" term="%22PLoS+Computational+Biology%22">PLoS Computational Biology</searchLink>. 6/22/2026, Vol. 22 Issue 6, p1-18. 18p.
– Name: Subject
  Label: Subject Terms
  Group: Su
  Data: *<searchLink fieldCode="DE" term="%22Software+libraries+%28Computer+programming%29%22">Software libraries (Computer programming)</searchLink><br />*<searchLink fieldCode="DE" term="%22Computational+neuroscience%22">Computational neuroscience</searchLink><br />*<searchLink fieldCode="DE" term="%22Bayesian+analysis%22">Bayesian analysis</searchLink><br />*<searchLink fieldCode="DE" term="%22Time-varying+networks%22">Time-varying networks</searchLink><br />*<searchLink fieldCode="DE" term="%22Neuromorphics%22">Neuromorphics</searchLink><br />*<searchLink fieldCode="DE" term="%22Hierarchical+Bayes+model%22">Hierarchical Bayes model</searchLink>
– Name: Abstract
  Label: Abstract
  Group: Ab
  Data: 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. Author summary: Many theories of brain function propose that perception and learning arise from Bayesian inference, in which the brain continuously updates beliefs about the causes of sensory inputs. One influential framework implementing this idea is predictive coding, where hierarchical networks exchange predictions and prediction errors to update internal beliefs. These models have been widely used to study learning, decision-making, and psychiatric conditions. However, applying predictive coding to complex models or large datasets remains difficult because existing tools are often specialized, inflexible, or poorly integrated with modern machine-learning and probabilistic programming frameworks. Here we introduce pyhgf, a software library for building and analysing dynamic predictive coding networks. The library implements the generalized hierarchical Gaussian filter, a model that represents how beliefs and their uncertainty evolve over time. In pyhgf, networks are composed of modular nodes that exchange predictions and prediction errors through local computations, making it possible to flexibly construct complex hierarchical models. The library is designed to integrate with modern computational tools, enabling efficient simulation, parameter estimation, and model comparison. By lowering the technical barriers to building predictive coding models, pyhgf provides a practical framework for studying adaptive behaviour and developing biologically inspired artificial agents. [ABSTRACT FROM AUTHOR]
PLink https://search.ebscohost.com/login.aspx?direct=true&site=eds-live&db=asx&AN=194756459
RecordInfo BibRecord:
  BibEntity:
    Identifiers:
      – Type: doi
        Value: 10.1371/journal.pcbi.1014340
    Languages:
      – Code: eng
        Text: English
    PhysicalDescription:
      Pagination:
        PageCount: 18
        StartPage: 1
    Subjects:
      – SubjectFull: Software libraries (Computer programming)
        Type: general
      – SubjectFull: Computational neuroscience
        Type: general
      – SubjectFull: Bayesian analysis
        Type: general
      – SubjectFull: Time-varying networks
        Type: general
      – SubjectFull: Neuromorphics
        Type: general
      – SubjectFull: Hierarchical Bayes model
        Type: general
    Titles:
      – TitleFull: pyhgf: A neural network library for predictive coding.
        Type: main
  BibRelationships:
    HasContributorRelationships:
      – PersonEntity:
          Name:
            NameFull: Legrand, Nicolas
      – PersonEntity:
          Name:
            NameFull: Weber, Lilian
      – PersonEntity:
          Name:
            NameFull: Waade, Peter Thestrup
      – PersonEntity:
          Name:
            NameFull: Møller Daugaard, Anna Hedvig
      – PersonEntity:
          Name:
            NameFull: Khodadadi, Mojtaba
      – PersonEntity:
          Name:
            NameFull: Mikuš, Nace
      – PersonEntity:
          Name:
            NameFull: Mathys, Christoph
    IsPartOfRelationships:
      – BibEntity:
          Dates:
            – D: 22
              M: 06
              Text: 6/22/2026
              Type: published
              Y: 2026
          Identifiers:
            – Type: issn-print
              Value: 1553734X
          Numbering:
            – Type: volume
              Value: 22
            – Type: issue
              Value: 6
          Titles:
            – TitleFull: PLoS Computational Biology
              Type: main
ResultId 1