All problems
Linear Layer Forward
Problem
Forward pass of a framework-style linear layer.
params is a dict with W of shape out x in and b of length out. Return W @ x + b as a list of length out.
Hint
Each output row is a dot product with x plus its bias.
Test cases
case 1
in: [[1,2],{"W":[[1,0],[0,1]],"b":[0,0]}]
expected: [1,2]
case 2
in: [[1,2],{"W":[[2,0]],"b":[1]}]
expected: [3]
case 3
in: [[0.5,-0.5],{"W":[[1,1]],"b":[0]}]
expected: [0]
case 4
in: [[1],{"W":[[3]],"b":[2]}]
expected: [5]
Starter codePython
def linear_layer(x, params):
# Your code here
pass4 test cases · run your code against them in the editor