利用pytorch进行线性回归
import torch import matplotlib.pyplot as plt torch.manual_seed(10) lr = 0.1 #learning rate #train data x = torch.rand(20,1)*10 #x data shape(20,1) y = 2*x+(5+torch.randn(20,1))#y data shape(20,1) #build model w = torch.randn((1),requires_grad=True) b = torch.zeros((1),requires_grad=True) for iterati
用户评论