All problems
MAML Inner Step
Problem
Run one MAML inner-loop gradient step on a linear model.
With prediction sum(w * x) and loss 0.5 * (pred - y)^2, the gradient is (pred - y) * x per weight. Return [adapted_weights, round(loss, 4)] where adapted_weights = w - lr * grad rounded to 4 decimal places.
Test cases
case 1
in: [[1,0],[2,1],0,0.1]
expected: [[0.6,-0.2],2]
case 2
in: [[0.5],[2],1,0.5]
expected: [[0.5],0]
case 3
in: [[1,1],[1,1],3,0.2]
expected: [[1.2,1.2],0.5]
Starter codePython
def maml_inner_step(weights, x, y, lr):
# Your code here
pass3 test cases · run your code against them in the editor