Skip to content
← All questions

Why does gradient descent oscillate when features are not scaled?

Gradient descent oscillates when features are not scaled because features with vastly different ranges cause the gradients with respect to their corresponding parameters to differ greatly. This leads to small step sizes for parameters of small-scale features and large step sizes for parameters of large-scale features, resulting in an inefficient, zigzagging path toward the minimum.

Conditions

  • Used in linear regression optimization with gradient descent.
  • Features have significantly different scales (e.g., one ranges from 0 to 1, another from 100 to 1000).

Reasoning, step by step

  1. Analyze the gradient descent update rule: the change in parameter θi\theta_i is proportional to the feature value xix_i.
  2. Observe that if x1x_1 is small, the step size for θ1\theta_1 will be small.
  3. Observe that if x2x_2 is large, the step size for θ2\theta_2 will be large.
  4. Conclude that this disparity in step sizes causes the optimization path to oscillate inefficiently across the narrow dimension of the cost function's contours, delaying convergence.

Example

The video visualizes this with a contour plot showing an elongated valley and a red zigzagging path moving towards the minimum, caused by x1∈(0,1)x_1 \in (0, 1) and x2∈(100,1000)x_2 \in (100, 1000).

Common misconceptions

  • Believing that a smaller learning rate fixes the oscillation without scaling; it only slows down the large steps, making the small steps even slower.
  • Assuming that gradient descent always takes a direct path to the minimum regardless of feature scales.

Watch the explanation

Explore next

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.