import torch torch.manual_seed(0) x = torch.linspace(0, 2, 20).unsqueeze(1) # shape (20, 1) y = 3 * x + 1 + 0.3 * torch.randn_like(x) # shape (20, 1)