利用pytorch进行线性回归

上传:zgchenhongjun 浏览: 24 推荐: 0 文件:PDF 大小:18.73KB 上传时间:2020-12-31 15:34:27 版权申诉
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
上传资源
用户评论