Premium problem51. Manual Linear Layer Forward Pass

Medium Locked

Compute the affine transform of a fully-connected layer: y = x @ W.T + b, where x is (batch, in_features), W is (out_features, in_features), and b is (out_features,).

Input

x =
tensor([[1., 2.],
        [3., 4.]])
W =
tensor([[ 0.5000, -0.5000],
        [ 1.0000,  2.0000],
        [ 0.0000,  1.0000]])
b = tensor([0.1000, 0.2000, 0.3000])

Output

tensor([[-0.4000,  5.2000,  2.3000],
        [-0.4000, 11.2000,  4.3000]])

Premium problem

This one's part of Premium. Unlock the full PyTorch track plus every other premium problem on the site.

Implement solve(...)