20/31
Part 5 of 6 · A Linear layer, proved by gradcheckLearn and do
Divide by the square root of in to keep the outputs' scale
A layer also has to start with weights of the right size.
torch.manual_seed(0)
x = torch.randn(1000, 400)
w = torch.randn(400, 300)
print(f"{(x @ w).std():.2f}", f"{(x @ (w / 400 ** 0.5)).std():.2f}")
x is (1000, 400) and w is (400, 300), both with spread 1. What is the spread of x @ w, and of x @ (w / √400)?
Pick one to see what it prints.
Pick an answer above to see the rest