Unit 1 of 11 · about 4 hours · derive, implement
Demonstrations, behavior cloning and action likelihoods
Behavior cloning is the baseline every offline method must beat. It needs no reward and no interaction, so its failure modes set the terms for everything later in this section.
You'll be able to
- Derive the behavior-cloning likelihood for discrete and continuous actions and implement it from a blank file.
- Choose an action distribution (logits, Gaussian parameters, or an expressive generative head) and defend the choice on multimodal data.
- Build a demonstration baseline with recorded data identity that later offline methods must beat.
Covers
Read
In this order, only the parts listed
0 of 4 done
- Lecture 2: Behavioral Cloning, from MLE to the BC algorithmBerkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Imitation and Offline RL
Part 1, maximum likelihood as supervised learning (PDF pp. 2-8); Part 2, demonstration trajectories and the ALVINN behavior-cloning algorithm (PDF pp. 9-12)
- The behavior-cloning objectiveHands-on Modern RL - Offline RL and Imitation Concepts
Section 1.1: discrete cross-entropy versus continuous MSE and negative log-likelihood, with the worked p = 0.7 versus p = 0.95 loss example (page read 2026-10-14)
- Lecture 02: expressive policy distributionsStanford CS224R Spring 2026 - Imitation and Offline RL
PDF pp. 6-21: the mean-of-modes failure of regression, generative policy heads, diffusion and flow matching, action chunking, and the unimodal versus multimodal summary
Stop before PDF p. 23. Compounding errors and DAgger belong to the next unit.
- Lecture 3: action distributions for imitationBerkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Imitation and Offline RL
PDF pp. 9-16: autoregressive discretization, expressive continuous distributions, flow matching, and action chunking
Focus on
- Behavior cloning is maximum likelihood on expert pairs. Discrete actions use logits with cross-entropy; continuous actions use distribution parameters with MSE or negative log-likelihood.
- A single number pins the loss scale: versus . Recompute both before trusting any training curve.
- An MSE head predicts the conditional mean. On multimodal demonstrations (two experts, two modes) the mean can be an action no expert took.
- Stanford Homework 1 fixes the control interface: policies predict a chunk of future targets and execute the first before replanning. The loss averages over the chunk; control uses only its head.
Common mistakes · 3
- Reading a falling validation loss as a working policy. Likelihood is measured under the expert state distribution; closed-loop return is measured under the learner's own distribution, and the two can disagree sharply.
- Fitting MSE to multimodal demonstrations and shipping the mean action. Check the action histogram first; a mean between two modes is a new, untested behavior.
- Tuning the chunk length as if it were only a loss detail. It also sets the open-loop execution horizon, so it changes the control problem, not just the gradient.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Write the behavior-cloning objective and name the loss for discrete and for continuous unimodal actions.Answer
Maximize the expected log probability of expert actions under the data. Discrete: cross-entropy over logits. Continuous unimodal: MSE or Gaussian negative log-likelihood over distribution parameters.
2.A policy assigns probability 0.7 to the expert action on one state and 0.95 on another. What is each negative log-likelihood?Answer
0.357 and 0.051. Higher expert probability means lower loss, and the scale is logarithmic, not linear.
3.Two demonstrators pass an obstacle on opposite sides. What does an MSE behavior-cloning policy do at the obstacle, and why is it wrong?Answer
It predicts the mean action, straight at the obstacle, which neither demonstrator took. The fix is an expressive multimodal head such as a mixture, diffusion, or flow-matching policy.
4.Stanford Homework 1 uses an action chunk of 20 with 10 executed steps. What does the policy output, and what does the rollout use?Answer
It outputs 20 future target positions and executes the first 10 open-loop before re-querying the policy. This receding-horizon control separates the loss horizon from the execution horizon.
Practice
- Berkeley CS 285 Homework 1: Imitation Learning (MSE and flow-matching policies)
Implement
MSEPolicyandFlowMatchingPolicyinsrc/hw1_imitation/model.pyplus the loop insrc/hw1_imitation/train.py; pass thresholds are reward 0.5 (MSE) and 0.7 (flow). Handout: https://rail.eecs.berkeley.edu/deeprlcourse/static/homeworks/hw1.pdfRuns on CPU. Needs a free WandB login. Compare the unimodal MSE policy against the expressive flow policy on multimodal data.
You're done when
Your hand NLL values match Python, and your HW1 MSE policy reaches the 0.5 reward threshold with the dataset identity recorded.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 11 more in the section
- Stanford CS224R Spring 2026 - Imitation and Offline RLStanford University · primary
Study Lecture 02 (imitation: behavior cloning, covariate shift, DAgger) and Lecture 07 (offline RL). Homework 1 (behavior cloning, flow matching and DAgger on a small Flappy Bird environment) runs on CPU; Homework 3 (AWAC, IQL and a stitching study) runs on cloud GPUs, so read it for the losses. Follow the Stanford honor code for course materials.
- Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Imitation and Offline RLUC Berkeley · required
Slides are public at https://rail.eecs.berkeley.edu/deeprlcourse/static/slides/lec-N.pdf; current videos are not, and the public Fall 2023 playlist numbers lectures differently. Study Lectures 2 and 3 (behavioral cloning) and Lectures 17 and 18 (offline RL). Homework 1 (MSE and flow-matching action-chunk policies) runs on a laptop CPU; Homework 5 (SAC+BC, IQL and FQL on OGBench) needs a GPU, so debug on the smallest task and treat full 1M-step sweeps as optional.
- Hands-on Modern RL - Offline RL and Imitation ConceptsWalking Labs · support
Use the offline data and distribution-shift page and the imitation chapter as pre-reading for BCQ, CQL, IQL, behavior cloning, DAgger and GAIL. They have no runnable offline or imitation scripts and no off-policy evaluation. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; its
code/chapterNNfolders do not follow the site chapter numbers.
Also in this section
- Offline Reinforcement Learning: Tutorial, Review and PerspectivesLevine et al. · required
Study the problem definition, distribution-shift failure, policy constraints, uncertainty and model-based/model-free taxonomy. Use it to state which offline assumptions each implementation relies on.
- Implicit Q-LearningKostrikov et al. · required
Derive the expectile value loss, Q target and advantage-weighted policy update. Implement fixed-batch loss tests and compare IQL with behavior cloning across dataset quality and coverage.
- Conservative Q-Learning for Offline Reinforcement LearningKumar et al. (NeurIPS 2020) · support
Read the conservative regularizer and the lower-bound argument. Implement the regularizer on a fixed batch and show how it lowers Q-values on actions the dataset does not contain.
- DAggerRoss, Gordon and Bagnell · support
Read the no-regret reduction and interactive data-aggregation loop. Demonstrate compounding error in a controlled imitation task, then show exactly what additional expert queries change.
- Generative Adversarial Imitation LearningHo and Ermon (NeurIPS 2016) · support
Read the occupancy-measure view of imitation and the discriminator-as-reward construction. State what GAIL needs that behavior cloning does not (environment interaction) and what it recovers instead of a reward.
- Cal-QL: Calibrated Offline RL Pre-Training for Efficient Online Fine-TuningNakamoto et al. (NeurIPS 2023) · support
Read why conservative values cause an initial dip when online fine-tuning starts and how calibration bounds the values. Measure the first online episodes after offline training with and without the fix.
- Doubly Robust Off-policy Value Evaluation for Reinforcement LearningJiang and Li (ICML 2016) · support
Read the per-decision importance-sampling estimator, the doubly robust form and its variance analysis. Implement ordinary, weighted and doubly robust estimates on logged trajectories from a small MDP whose true value you can compute.
- Batch Policy Learning under Constraints (Fitted Q Evaluation)Le, Voloshin and Yue (ICML 2019) · support
Read the Fitted Q Evaluation algorithm and its role inside the constrained learner. Implement FQE on your logged data and compare it with the importance-sampling estimates against the true value.
- Benchmarks for Deep Off-Policy EvaluationFu et al. (ICLR 2021) · support
Read the evaluation protocol and the metrics for estimator quality and offline model selection (rank correlation, regret of the selected policy). Use them to judge your estimators instead of one point error.
- Minari Offline DatasetsFarama Foundation · support
Use Minari as the dataset source for offline experiments: it serves Gymnasium-native datasets that download without login (start with a small MuJoCo set such as
mujoco/invertedpendulum/expert-v0). Record the dataset id and version with every result. - Reinforcement Learning Control Laboratory - Offline StretchRoadmap-Final · support
Add the project offline-data stretch only after online control passes. Calibrate importance or fitted-value estimates against simulator truth and expose one support-mismatch failure before hiding online access.