Why must training data be shuffled between epochs in mini-batch gradient descent?

Quick Overview

Asks why mini-batch gradient descent reshuffles the training data every epoch and what happens when data is fed in a fixed or sorted order. Tests understanding of unbiased gradient estimates, order effects, gradient noise, and exceptions such as time series.

Why must training data be shuffled between epochs in mini-batch gradient descent?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

Why must training data be shuffled between epochs in mini-batch gradient descent? Explain what goes wrong without shuffling and when keeping an order is acceptable. ```hint Picture a sorted dataset Imagine the data is stored sorted by label and you take batches in that order. What does each batch's gradient look like compared with the gradient over the whole dataset? ``` ### What a Strong Answer Covers - Why each mini-batch gradient should be a representative, unbiased estimate of the full gradient, and how ordered data breaks that - What a fixed batch order across epochs causes (recency effects, repeating update cycles) - How fresh batch compositions change the gradient noise and its effect on generalization - The exceptions, such as time series and curriculum learning, and how shuffling is adapted there - How shuffling is turned on in common frameworks ### Follow-up Questions - If the data is shuffled once before training, what do you lose by not reshuffling every epoch? - `tf.data` shuffles with a buffer. When is a buffer smaller than the dataset not enough? - In distributed data-parallel training, how do you make sure every worker sees a new order each epoch? - For a time series forecasting model, how would you build batches so training stays stable without leaking the future?

Overview: Asks why mini-batch gradient descent reshuffles the training data every epoch and what happens when data is fed in a fixed or sorted order. Tests understanding of unbiased gradient estimates, order effects, gradient noise, and exceptions such as time series.

PracHub logo
General
Nov 25, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

Why must training data be shuffled between epochs in mini-batch gradient descent? Explain what goes wrong without shuffling and when keeping an order is acceptable.

What a Strong Answer Covers Guidance

  • Why each mini-batch gradient should be a representative, unbiased estimate of the full gradient, and how ordered data breaks that
  • What a fixed batch order across epochs causes (recency effects, repeating update cycles)
  • How fresh batch compositions change the gradient noise and its effect on generalization
  • The exceptions, such as time series and curriculum learning, and how shuffling is adapted there
  • How shuffling is turned on in common frameworks

Follow-up Questions Guidance

  • If the data is shuffled once before training, what do you lose by not reshuffling every epoch?
  • tf.data shuffles with a buffer. When is a buffer smaller than the dataset not enough?
  • In distributed data-parallel training, how do you make sure every worker sees a new order each epoch?
  • For a time series forecasting model, how would you build batches so training stays stable without leaking the future?