- 博客(3)
- 收藏
- 关注
原创 2021-05-04
简单的一元线性回归模型1 导入需要的包,设置随机数种子,设置学习率#导入需要用到的包import torchimport matplotlib.pyplot as plttorch.manual_seed(10) #设置随机种子种子lr = 0.05 #设置学习率2 创建训练数据X为随机的正太分布,y=2×X+(5+torch.randn(20,1))x = torch.rand(20, 1) * 10 # 随机生成Xy
2021-05-04 13:15:05 56 1
原创 pytorch学习笔记二
张量的操作1 张量的拼接1.1 torch.cat(input,dim) 将张量按照dim进行拼接,不会扩张维度t = torch.ones((2, 3)) t_0 = torch.cat([t, t], dim=0) t_1 = torch.cat([t, t], dim=1) t_2 = torch.cat([t, t ,t], dim=1) print("t_0:{} shape:{}\nt_1:{} shape:{}\nt_2:{} shape:{.
2021-05-04 00:37:09 197
原创 pytorch学习笔记一
张量的创建1 直接创建张量1.1通过torch.tensor创建张量arr = np.ones((3, 3)) print("ndarray的数据类型:", arr.dtype) t = torch.tensor(arr, device='cuda') #gpu版本 t = torch.tensor(arr) #cpu版本 print(t)1.2 通过torch.from_numpy创建张量arr = np...
2021-05-03 00:54:24 101
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人