Adding Momentum
Plain gradient descent has no memory: each move is decided from the steepness underfoot and nothing else, so a run crossing a long narrow valley zig-zags from wall to wall and creeps forward. Kestrel Freight's trainer offers momentum instead, which gives the dial something like weight. The dial carries a speed from one move to the next. On each move a fixed fraction of the old speed survives — that fraction is beta, so a larger beta remembers more of where the run was already going — and the current steepness only adds to that speed rather than replacing it, contributing the learning rate's worth of itself. The dial then travels downhill by the whole of the new speed.
Task: Take one momentum step and print where the dial lands.
Input
One line holding five numbers separated by single spaces: the dial's current setting, the steepness at that setting, the learning rate, beta, and the speed carried in from the previous move.
Output
One line: the word w1, a single space, and the dial's setting after this one move, rounded to 4 decimal places.
Example:
Input:
5 2 0.1 0.9 0
Output:
w1 4.8000
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in