- 博客(8)
- 收藏
- 关注

原创 一个月Pytorch笔记
一个月Pytorch从入门到实践学习时间:学习内容:3-2 张量,标量,向量,矩阵3-3 tensor创建理论3-4 tensor创建代码3-5 tensor创建代码学习总结:学习时间:1、 周六上午 9 点-上午 12 点2、学习内容:3-2 张量,标量,向量,矩阵3-3 tensor创建理论tensor 类型 torch.float ; torch.bool ; torch.int tensor创建 3-4 tensor创建代码import torch
2020-10-28 08:54:49
329
原创 波斯顿房价 (1)
#房价预测import torch#dataimport numpy as npimport reff = open(r"C:\Users\22383\Desktop\备份pytorch\000、课程配套资料\Pytorch_code-master\pytorch_code\04\cls_reg\housing.data").readlines()data = []for item in ff: out = re.sub(r"\s{2,}", " ", item).strip()
2020-11-01 17:36:38
179
原创 pytorch任课(第三章)
import torch#torch.wherea = torch.rand(4, 4)b = torch.rand(4, 4)print(a)print(b)tensor([[0.4295, 0.4639, 0.1673, 0.8253], [0.6463, 0.0885, 0.6070, 0.9644], [0.3394, 0.3260, 0.6519, 0.7562], [0.7720, 0.7656, 0.3653, 0.3863]]
2020-10-29 22:34:00
172
原创 3-11比较运算-排序
import torcha = torch.rand(2, 3)b = torch.rand(2, 3)print(a)print(b)tensor([[0.2165, 0.9520, 0.2256], [0.0793, 0.1522, 0.3120]])tensor([[0.8147, 0.2384, 0.1755], [0.6711, 0.9985, 0.4503]])#维度相同才可以比较print(torch.eq(a, b)) #返回一个te
2020-10-28 10:51:25
134
原创 3-10取整取余运算
import torcha = torch.rand(2, 2)a = a * 10print(a)print(torch.floor(a)) #向下取整print("-----\n",a)print(torch.ceil(a)) #向上取整print(torch.round(a)) #四舍五入print(torch.trunc(a)) #留整数部分print(torch.frac(a))
2020-10-28 10:05:30
1738
原创 3-9广播机制
import torcha = torch.rand(2, 2)b = torch.rand(1, 2)# a, 2*1# b, 1*2# c, 2*2# 2*4*2*3c = a + bprint(a)print(b)print(c)print(c.shape)tensor([[0.3246, 0.0065], [0.5726, 0.3850]])tensor([[0.3750, 0.1614]])tensor([[0.6996, 0.1680],
2020-10-28 09:41:21
73
原创 3-8tensor算术运算编程
import torch##adda = torch.rand(2, 3)b = torch.rand(2, 3)print(a)print(b)print(a + b)print(a.add(b))print(torch.add(a, b))print(a)print(a.add_(b))print(a)tensor([[0.8129, 0.6266, 0.2343], [0.4351, 0.9933, 0.0969]])tensor([[0.4357
2020-10-28 09:30:43
162
1
原创 3-4 tensor 创建
import torch# 1 直接定义a=torch.Tensor([[1,2],[3,4]])print(a)print(a.type())#type 有括号tensor([[1., 2.], [3., 4.]])torch.FloatTensor# 2 通过shape定义,值随机a=torch.Tensor(2,3) # 无括号print(a)print(a.shape) tensor([[ 0.0000e+00, -1.1152e-01, 5.2
2020-10-24 10:30:11
143
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人