TorchedUp
ProblemsPremium
TorchedUp
SGD with MomentumMedium
ProblemsPremium

SGD with Momentum

Implement a single SGD with momentum parameter update.

Signature: def sgd_momentum_step(theta: np.ndarray, grad: np.ndarray, v: np.ndarray, lr: float = 0.01, mu: float = 0.9) -> np.ndarray

Return the updated theta_new.

  • Velocity update: v = mu*v - lr*grad
  • Parameter update: theta += v

Math

Asked at

Python (numpy)0/3 runs today

Test Results

○first step no prior velocity
○second step with velocity
○negative gradient🔒 Premium
Advertisement