![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pytorch笔记
文章平均质量分 59
caoqh
这个作者很懒,什么都没留下…
展开
-
pytorch笔记47-49 logistic regression与交叉熵
文章目录logistic regression交叉熵二分类问题logistic regression其实它是一个分类算法regression与classification:优化目标不同regression:minimize(pred,y)classification:minimize dist (Ptheat,Preal)为何不是maximize accuracy?当预测值与实际值不等,但概率从0.3上升到0.4,ACC值并未改变(这时未达到阈值,判定预测错误),但是概率趋近,原创 2021-02-02 19:48:10 · 202 阅读 · 0 评论 -
pytorch笔记34-45随机梯度下降(反向传播算法)
文章目录激活函数的梯度loss的梯度感知机的梯度推导激活函数的梯度sigmoid/logistica = torch.linspace(-100,100,10)torch.sigmoid(a)RELU/Rectified Linear Unit# 两种调用,F.relu/torch.relufrom torch.nn import functional as Fa = torch.linspace(-1,1,10)torch.relu(a)F.relu(a)loss的梯度原创 2021-01-30 14:25:03 · 215 阅读 · 0 评论 -
pytorch笔记24-33数据进阶操作
文章目录合并与分割数据的运算数据的属性统计进阶操作合并与分割cat合并操作a = torch.rand(4,32,8)b = torch.rand(5,32,8)torch.cat([a,b],dim=0).shape# torch.Size([9, 32, 8])stack合并:create new dim创建一个新的维度,要求两个tensor.shape完全一样a = torch.rand(32,8)b = torch.rand(32,8)torch.stack([a,b],dim原创 2021-01-28 14:25:16 · 97 阅读 · 0 评论 -
pytorch笔记18-23数据操作(维度变换4)
文章目录索引操作维度变换数据转置索引操作索引操作a = torch.IntTensor(4,3,28,28)# 对第一张和第二张图片索引a.index_select(0,torch.tensor([0,2]))#第一个参数为哪一个维度 第二个参数要求为tensor类型的list# ...代表任意维度a[...].shape# torch.Size([4, 3, 28, 28])a[0,...].shape# torch.Size([3, 28, 28]) 第一张图片# sel原创 2021-01-27 11:53:54 · 119 阅读 · 0 评论 -
pytorch笔记14-17创建tensor(数据类型)
文章目录1. 基本数据类型2. 创建tensor3. type-check1. 基本数据类型Dimension 0/rank 0 ,0维数据(标量)torch.tensor(1.0)# out:tensor(1.)torch.tensor(1.3)# out:tensor(1.300)# 查看数据类型a = torch.tensor(2.2)a.shape # 注意这里是shape没有括号,不是一个成员函数,与size()区分# out:torch.Size([])len(a.s原创 2021-01-23 16:52:26 · 414 阅读 · 2 评论