Skip to content

Commit

Permalink
Merge branch 'master' into coupling
Browse files Browse the repository at this point in the history
  • Loading branch information
LegrandNico authored Jul 31, 2023
2 parents 45f7348 + 5ff5101 commit f8d9dea
Show file tree
Hide file tree
Showing 31 changed files with 2,287 additions and 859 deletions.
4 changes: 2 additions & 2 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[settings]
known_third_party = aesara,arviz,bokeh,jax,matplotlib,numba,numpy,numpyro,pkg_resources,pymc,pytest
known_third_party = aesara,arviz,bokeh,jax,matplotlib,numpy,numpyro,pkg_resources,pymc,pytest
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 88
line_length = 88
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# The multilevel, generalized and nodalized Hierarchical Gaussian Filter for predictive coding

pyhgf is a Python library that implements the generalized, nodalized and multilevel Hierarchical Gaussian Filters for predictive coding written on top of [JAX](https://jax.readthedocs.io/en/latest/jax.html). The library can create and manipulate graph neural networks that perform beliefs update throught the diffusion of precision-weighted prediction errors under new observations. The core functions are derivable, JIT-able, and are designed to interface smoothly with other libraries in the JAX ecosystem for Bayesian inference.
pyhgf is a Python library that implements the generalized, nodalized and multilevel Hierarchical Gaussian Filters for predictive coding written on top of [JAX](https://jax.readthedocs.io/en/latest/jax.html). The library can create and manipulate graph neural networks that perform belief update through the diffusion of precision-weighted prediction errors under new observations. The core functions are derivable, JIT-able, and are designed to interface smoothly with other libraries in the JAX ecosystem for Bayesian inference.

* 🎓 [What is a Hierarchical Gaussian Filter?](https://ilabcode.github.io/pyhgf/theory.html)
* 📖 [API Documentation](https://ilabcode.github.io/pyhgf/)
Expand All @@ -29,15 +29,15 @@ The nodalized Hierarchical Gaussian Filter consists of a network of probabilisti
More generally, pyhgf operates on graph neural networks that can be defined and updated through the following variables:

* The node parameters (dictionary) that store each node's parameters (value, precision, learning rates, volatility coupling, ...).
* The node structure (tuple) that list, for each node, the indexes of the value and volatility parents.
* The node structure (tuple) that lists, for each node, the indexes of the value and volatility parents.
* A set of update functions that operate on any of the 3 other variables, starting from a target node.
* An update sequence (tuple) that define the order in which the update functions are called, and the target node.

![png](./docs/source/images/graph_networks.svg)

Value parent and volatility parent are nodes themself. Any node can be a value and/or volatility parent for other nodes and have multiple value and/or volatility parents. A filtering structure consists of nodes embedding other nodes hierarchically. Nodes are parametrized by their sufficient statistic and parents. The transformations between nodes can be linear, non-linear, or any function (thus a *generalization* of the HGF).

The resulting probabilistic network operates as a filter towards new observation. If a decision function (taking the whole model as a parameter) is also defined, behaviours can be triggered accordingly. By comparing those behaviours with actual outcomes, a surprise function can be optimized over the range of parameters of interest.
The resulting probabilistic network operates as a filter toward new observation. If a decision function (taking the whole model as a parameter) is also defined, behaviors can be triggered accordingly. By comparing those behaviors with actual outcomes, a surprise function can be optimized over the range of parameters of interest.

### The Hierarchical Gaussian Filter

Expand All @@ -49,7 +49,7 @@ The pyhgf package includes pre-implemented standard HGF models that can be used

### Model fitting

Here we demonstrate how to fit a two-level binary Hierarchical Gaussian filter. The input time series are binary outcome from Iglesias et al. (2013).
Here we demonstrate how to fit a two-level binary Hierarchical Gaussian filter. The input time series are the binary outcomes from Iglesias et al. (2013).

```python
from pyhgf.model import HGF
Expand Down Expand Up @@ -87,7 +87,7 @@ hgf.plot_trajectories()

# Acknoledgements

This implementation of the Hierarchical Gaussian Filter was largely inspired by the original [Matlab version](https://translationalneuromodeling.github.io/tapas). A Julia implementation of the generalised, nodalised and multilevel HGF is also available [here](https://github.com/ilabcode/HGF.jl).
This implementation of the Hierarchical Gaussian Filter was largely inspired by the original [Matlab version](https://translationalneuromodeling.github.io/tapas). A Julia implementation of the generalized, nodalised and multilevel HGF is also available [here](https://github.com/ilabcode/HGF.jl).

## References

Expand Down
2 changes: 2 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,5 @@ Utilities for manipulating node structures and applying sequences.
:toctree: generated/pyhgf.structure

beliefs_propagation
trim_sequence
list_branches
Binary file added docs/source/images/response_models.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/source/notebooks/0-Creating_networks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/notebooks/0-Creating_networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.14.5
jupytext_version: 1.14.7
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down
120 changes: 49 additions & 71 deletions docs/source/notebooks/0-Theory.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit f8d9dea

Please sign in to comment.