求解步骤 1.确定模型 y = wx +b 2.选择损失函数 MSE 3.求解梯度并更新w, b 梯度下降法求解 代码 import torch import matplotlib.pyplot as plt torch.manual_seed(10) lr = 0.1 #创建训练数据 x = torch.rand(20,1) * 10 y = 2 * x + (5 + torch.rand(20,1)) #构造线性回归参数 w = torch.randn