lin = nn.Linear(1, 1) xx = torch.randn(5, 1) print(torch.allclose(lin(xx), xx @ lin.weight.T + lin.bias)) # True