1import torch
2import torch.nn as nn
3
4x = torch.tensor([[1.0, -1.0],
5 [0.0, 1.0],
6 [0.0, 0.0]])
7
8in_features = x.shape[1] # = 2
9out_features = 2
10
11m = nn.Linear(in_features, out_features)
12%%%%
13results would be
14>>> m.weight
15tensor([[-0.4500, 0.5856],
16 [-0.1807, -0.4963]])
17
18>>> m.bias
19tensor([ 0.2223, -0.6114])
20%%%%