Skip to content
DeepForgeby svx
All problems
HardOptimizationop-159

SAGA Table Update

Problem

Perform one SAGA update for a single coordinate group.

Compute v = grad_i - table_i + avg_grad and w_new = w - lr * v. Replace the table entry with grad_i and update the running average as avg_grad + (grad_i - table_i) / n. Return [w_new, table_new, avg_new].

Hint

The table entry and the running average must both be refreshed.

Test cases

case 1
in: [1,0.5,0.4,0.45,0.1,4]
expected: [0.945,0.5,0.475]
case 2
in: [0,-1,0.5,0,0.5,2]
expected: [0.75,-1,-0.75]
case 3
in: [2,0,0,0.25,0.2,5]
expected: [1.95,0,0.25]
Starter codePython
def saga_table_update(w, grad_i, table_i, avg_grad, lr, n):
    # Returns [w_new, table_new, avg_new]
    # Your code here
    pass

3 test cases · run your code against them in the editor