Skip to article content

Self-orthogonalizing attractor neural networks emerging from the free energy principle

Back to Article
UML diagram of the network implementation
Download Notebook

UML diagram of the network implementation

The implementation favors clarity over efficiency - it implements both σ and boundary states as separate classes, and is not optimized for performance. A crucial detail for the implementation of the learning rule is that - in line with the our formal framework - the predictive (anti-Hebbian) term uses the previous state of the network, before the new biases (novel input/evidence) were applied.

import subprocess
from IPython.display import Image, display

# Run pyreverse to generate a single UML diagram focusing on State classes, ignoring others
subprocess.run(['pyreverse', 
                '-o', 'png', 
                '--colorized', 
                '-p', 'network_state', # Project name
                '-ASmy', # Show Attributes, Methods, builtins, associations
                'simulation/network.py'])

# Display the generated UML diagram
display(Image(filename='classes_network_state.png')) # Match project name
Format png is not supported natively. Pyreverse will try to generate it using Graphviz...
<IPython.core.display.Image object>
Attractor networks and active inference
Simulation 4