VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
DSA for AI/ML · Module 04: Sliding window

Lesson 4.9 of 10 in this module Unrolled Pro

Rolling Mean of Training Loss

An ML twin: smooth a noisy training-loss curve with a rolling mean over the last w steps. From averaging every window from scratch (O(n·w)), to a running sum with a queue (O(n), O(w) memory), to an exponential moving average with bias correction (O(1) memory, what dashboards use). Then NaNs, float drift, time-based windows over irregular logs, and rolling medians.

about 10 min 4 Python examples 2 quick checks

Task. Given per-step training losses, return the rolling mean over the last w steps at every step. Before step w, average whatever steps exist so far.

text
losses = [4.0, 2.0, 3.0, 1.0, 2.0], w = 3
→ [4.0, 3.0, 3.0, 2.0, 2.0]      (4/1, 6/2, 9/3, 6/3, 6/3)

ML context. Raw per-step loss is noisy: minibatches differ, learning rates warm up, some batches are hard. Every training dashboard smooths it so you can see the trend, decide on early stopping, or catch a divergence. The two standard smoothers are the rolling mean (a window) and the exponential moving average (what the smoothing slider in most dashboards does). Both need to run per step, forever, without slowing training down.


1. Step 1: Clarify

That's the preview. Modules 00–01 are free; this lesson is part of Unrolled Pro.
Staff AI & Pro Tier Lesson

Unlock "Rolling Mean of Training Loss"

The foundations are free forever. Unrolled Pro unlocks the complete lesson, production architectures, and 55 battle-tested ML system design case studies.

Everything included with Pro:
All 234+ Deep-Dive Lessons across transformer internals, inference, RAG & agents
55 Staff-Level ML & System Design Case Studies with mathematical capacity estimates
AI Engineer Sheet & Exercises with worked solutions, self-checks, and code
100 Landmark Research Papers guided walkthroughs & progress tracking
14-Day Money-Back Guarantee — 100% full refund if you aren't satisfied
View Plans & Unlock All Lessons

From ₹167/mo (~$2/mo) · Cancel anytime · Instant activation

100% Risk-Free: 14-day no-questions-asked money-back guarantee