Stanford CS221 | Autumn 2025 | Lecture 12: Bayesian Networks I
TL;DR
This lecture transitions from model-free and model-based reinforcement learning to probabilistic reasoning, introducing Bayesian networks as a framework for representing uncertain world states. It establishes probability fundamentals—joint distributions, marginalization, and conditioning—using tensor operations (einops) to provide the mathematical foundation for efficient inference in complex domains.
🧠 Model-Based vs. Model-Free Intelligence 3 insights
Model-free methods are direct but inflexible
Approaches like Q-learning compile rewards and transitions into direct predictions, making it impossible to adapt if the reward function changes without completely retraining the model.
Model-based reasoning enables flexible planning
Understanding how the world works allows agents to recompute optimal policies on the fly when objectives change, whereas Q-values permanently bake in the original reward structure.
Bayesian networks model uncertain world states
The lecture shifts from deterministic search and MDPs to representing the world probabilistically, addressing how agents reason under uncertainty about multiple interrelated state variables.
📊 Probability as Tensor Operations 3 insights
Joint distributions represent complete world states
A joint distribution over random variables assigns probabilities to every possible assignment of values, serving as a comprehensive 'source of truth' for all possible world configurations.
Probability tables are multi-dimensional tensors
Joint distributions map directly to tensors where each axis corresponds to a random variable, enabling efficient computation using linear algebra rather than manual table lookups.
Einops notation expresses all probability laws
Marginalization and other operations can be written compactly using einops (einsum) notation, where summing over axes not present in the output label corresponds to marginalizing out variables.
🔍 Core Inference Operations 3 insights
Marginalization collapses uncertain variables
To ignore a variable, sum probabilities over all assignments that differ only in that variable, effectively collapsing the probability table by removing the corresponding dimension.
Conditioning selects and renormalizes evidence
Observing evidence selects compatible assignments from the joint distribution, then divides by the evidence probability to renormalize, yielding a valid probability distribution over remaining variables.
Inference queries act like SQL on databases
Probabilistic inference treats the joint distribution as a database, allowing queries that specify evidence variables and request probabilities for query variables while automatically marginalizing all unmentioned variables.
Bottom Line
To reason under uncertainty, represent the world as a joint probability distribution over random variables and use marginalization to ignore unknowns and conditioning to incorporate evidence—foundations that Bayesian networks will make computationally tractable for complex domains.
More from Stanford Online
View all
Stanford CS153 Frontier Systems | Nikhyl Singhal from Skip on Product Management in the AI Era
Nikhyl Singhal argues that product management is evolving from manual information gathering to AI-augmented strategic judgment, requiring PMs to focus on solving genuine customer problems while leveraging AI's ability to synthesize vast customer data streams.
Stanford CS153 Frontier Systems | Amit Jain from Luma AI on Unified Intelligence Systems
Amit Jain details Luma AI's evolution from 3D capture to video generation, revealing how the company learned to build scalable world simulators by designing algorithms around data physics rather than theoretical ideals, ultimately converging on unified intelligence systems that combine language, video, and reasoning.
Stanford CS153 Frontier Systems | Andreas Blattmann from Black Forest Labs on Visual Intelligence
Andreas Blattmann, co-founder of Black Forest Labs and co-creator of Stable Diffusion, argues that visual intelligence represents the critical next frontier for AI, requiring a fundamental shift from text-centric unimodal models to multimodal systems trained on 'natural representations' (video, audio, physics) to unlock true reasoning, robotics capabilities, and higher intelligence.
Stanford CS153 Frontier Systems | Mati Staniszewski from ElevenLabs on The Future of Voice Systems
ElevenLabs CEO Mati Staniszewski explains how the company pivoted from an AI dubbing vision to perfecting text-to-speech by staying close to Discord communities, leveraging open-source research, and running lean to solve the 'one voice' dubbing problem he experienced growing up in Poland.