Weight and Parameters in nn.linear

print(torch.nn.Linear(3, 1).weight)
print(torch.nn.Linear(3, 1).bias)
print(list(torch.nn.Linear(3, 1).parameters()))

Results:
Parameter containing:
tensor([[0.4428, 0.3657, 0.0139]], requires_grad=True)
Parameter containing:
tensor([0.3234], requires_grad=True)
[Parameter containing:
tensor([[ 0.3756, 0.2845, -0.3558]], requires_grad=True), Parameter containing:
tensor([-0.4788], requires_grad=True)]

Can you explain the difference between weight, bias and parameters in nn.linear?
What does it choose to calculate the forward path?

I couldn’t do better with these equations.


(See documentation for more information)
(See wiki/Random_seed for more information about random seed).

1 Like