- 博客(3)
- 收藏
- 关注
原创 2021-05-04
简单的一元线性回归模型 1 导入需要的包,设置随机数种子,设置学习率 #导入需要用到的包 import torch import matplotlib.pyplot as plt torch.manual_seed(10) #设置随机种子种子 lr = 0.05 #设置学习率 2 创建训练数据 X为随机的正太分布,y=2×X+(5+torch.randn(20,1)) x = torch.rand(20, 1) * 10 # 随机生成X y
2021-05-04 13:15:05
152
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
355
原创 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
179
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅