import torch from torch import nn torch.manual_seed(11) features = torch.tensor( [ [0.0, 0.5], [1.0, 1.5], [2.0, 2.5], [3.0, 3.5], ], dtype=torch.float32, ) targets = features @ torch.tensor([[0.4], [-0.2]]) + 0.1 model = nn.Linear(2, 1) loss_fn = nn.MSELoss() optimizer = torch.optim.SGD(model.parameters(), lr=0.05)