Marginal

Active Inference

The free-energy principle as a theory of perception and action: the Bayesian brain, generative models with A, B, C and D matrices, variational free energy and surprise, perception as inference, predictive coding and precision, Markov blankets, expected free energy with its risk and ambiguity terms, epistemic and pragmatic value, policy selection, learning, and how active inference relates to reinforcement learning and bounded rationality.

18 lessons in 2 units

Start your free trial14 days free. No card needed.
What you'll learn

18 lessons, one small step at a time

Each lesson states its goal, then works up to it in short steps with practice after each. A placement test at the start skips what you already know.

Perception as Inference

11 lessons
  1. Perception as Bayes' ruleInfer the hidden cause of a sensation with Bayes' rule, and explain illusions as the work of priors.
  2. Surprise & model evidenceCompute the model evidence of an observation and its surprise.
  3. Likelihood matricesPredict observations from a belief with a likelihood matrix, and update the belief on an observation.
  4. Generative modelsPredict states with transition matrices, alternate prediction and update, and assemble the four arrays of a discrete generative model with its policies.
  5. Variational free energyCompute the variational free energy of a belief, and explain why it bounds surprise.
  6. Complexity & accuracySplit free energy into complexity and accuracy, and use the split to compare beliefs.
  7. Perception as inferenceFind the belief that minimizes free energy, and the value free energy then takes.
  8. Prediction-error updatesCompute precision-weighted prediction errors, take a prediction-error update, and find where the updates settle.
  9. Predictive codingFind where predictive-coding updates settle, and describe a hierarchy of predictions and errors.
  10. Precision & attentionCompute how precision weights the evidence, and explain what goes wrong when precision is set badly.
  11. Markov blanketsFind the Markov blanket of a node in a Bayesian network, and describe the active-inference partition of agent and world.

Action as Inference

7 lessons
  1. RiskCompute the risk of a policy as its divergence from preferred outcomes, and read preferences as rewards.
  2. Expected free energyCompute the expected free energy of a policy as risk plus ambiguity, and compare it with expected utility.
  3. Epistemic & pragmatic valueCompute the information an observation is expected to bring, and explain the explore-then-exploit behavior it produces.
  4. Policy selectionCompute policy probabilities from expected free energies, read the policy precision, and turn a belief about policies into a next action.
  5. Planning over timeCount the policies a planner compares, add up expected free energy over time, and find when checking a cue pays.
  6. Learning in active inferenceTurn Dirichlet counts into probabilities, update the counts after an observation, and explain the novelty they produce.
  7. Scope & critiquesRelate active inference to other frameworks, state the main critiques, and judge what the evidence supports.
Sample lesson

Perception as Bayes' rule

Goal: Infer the hidden cause of a sensation with Bayes' rule, and explain illusions as the work of priors.

In 1867 Hermann von Helmholtz described perception as "unconscious inference": the brain guesses the causes of its sensations. The modern Bayesian brain hypothesis makes this precise, and Karl Friston's active inference extends it from perception to action.

We will infer hidden causes and finish with priors in perception.

Step 1: Inferring hidden causes

The brain holds a generative model p(o, s) = p(o | s)p(s) of how hidden states s, the causes, produce observations o. Perceiving means computing, or approximating, the posterior:

p(s | o) = p(o | s)p(s) ÷ p(o)

In odds form, the posterior odds of two causes are the prior odds times the likelihood ratio p(o | s₁) ÷ p(o | s₂). Example: a shaded patch is a bump with prior odds 1 to 3 against a dent, and the shading is 6 times as likely under a bump. The posterior odds are 6 to 3, that is 2 to 1, so the bump has probability ⅔.

0.5prior p(bump)0.8posterior p(bump | shading)

p(bump | shading) = 0.4 ÷ 0.5 = 0.8.

Shading that is more likely under a bump moves belief toward a bump. When p(shading | bump) is also 0.2, the evidence cannot tell the causes apart and the posterior equals the prior.

Step 2: Priors in perception

Helmholtz's inference is automatic: no one decides to perceive. When sensory evidence is weak or ambiguous, the likelihood barely separates the causes and the posterior follows the prior. Visual illusions are the brain applying sensible priors to ambiguous input. Light usually comes from above, so shaded discs look like bumps, and turned upside down they look like dents. Faces bulge outward, so a hollow mask seen from behind looks convex. Rooms have right-angled corners, so a distorted room looks rectangular. Objects tend to move slowly, so faint moving stripes look slower than they are.

In the app, each step ends with practice questions, new ones every time, and the lesson comes back later in spaced reviews.

Start Active Inference

Lessons that need something you haven't learned yet bring it in first, from any course.

Start your free trial14 days free. No card needed.