Loading...
Update velocity and parameters using Momentum optimization.
Momentum helps accelerate gradients in the right direction and dampens oscillations. The update rules are:
v=β⋅v+(1−β)⋅dW W=W−α⋅v
Where:
Write a function momentum_step(weight, grad, velocity, beta, learning_rate) that returns a tuple of (updated_weight, updated_velocity).
Return a tuple (weight, velocity) with values rounded to 4 decimal places.
weight=0.0, grad=1.0, velocity=0.0, beta=0.9, learning_rate=0.1
(-0.01, 0.1)
v = 0.9×0 + 0.1×1 = 0.1; w = 0 - 0.1×0.1 = -0.01