随笔分类 -  深度学习&机器学习&机器学习 / 深度学习-pyTorch

摘要:# 1 标量的导数 ![image](https://img2023.cnblogs.com/blog/1914163/202308/1914163-20230801204951013-651864837.png) # 2 亚导数 比如说$y=|x|$这个函数在x=0的时候时不可导的。当x>0,其到 阅读全文
posted @ 2023-08-02 23:29 lipu123 阅读(238) 评论(0) 推荐(0)
摘要:Tensor advanced operation ▪ Where ▪ Gather # where 返回的最终的tensor中的每一个值有可能来着A,也有可能来自B。 >torch.where(condition,A,B)->tensor 满足condition条件则该位置为A[..],否则为B[ 阅读全文
posted @ 2023-07-31 23:14 lipu123 阅读(50) 评论(0) 推荐(0)
摘要:statistics ▪ norm (范数) ▪ mean,sum (平均值,求和) ▪ prod (累乘) ▪ max, min, argmin, argmax ▪ kthvalue, topk(第k大) # norm(范式) 这里面有一范式和二范式。 一范式: $$||x||_1=\sum_k| 阅读全文
posted @ 2023-07-31 21:47 lipu123 阅读(292) 评论(0) 推荐(0)
摘要:Math operation ▪ Add/minus/multiply/divide(加减乘除) ▪ Matmul(矩阵相乘) ▪ Pow(次方) ▪ Sqrt/rsqrt(次方根) ▪ Round() add/minus/multiply/divide 这个使用的时候可以直接使用运算符"+,-,* 阅读全文
posted @ 2023-07-31 14:50 lipu123
摘要:Merge or split ▪ Cat(合并) ▪ Stack(合并) ▪ Split(拆分) ▪ Chunk(拆分) # 合并 ## cat 这个就是合并两个tensor 比如说有两个班级的成绩单,一个是1-4班的,一个是5-9班的,我们现在需要合并这两份成绩单。 ▪ Statistics ab 阅读全文
posted @ 2023-07-31 10:10 lipu123 阅读(187) 评论(0) 推荐(0)
摘要:Broadcasting是一种没有copy数据的expand Key idea: - 不过两个维度不相同,在前面插入维度1 - 扩张维度1到相同的维度 例如:Feature maps:[4,32,14,14] Bias:[32,1,1]=>[1,32,1,1]=>[4,32,14,14] A:[32 阅读全文
posted @ 2023-07-30 22:19 lipu123 阅读(99) 评论(0) 推荐(0)
摘要:▪ View/reshape(这个是维度的变化) ▪ Squeeze/unsqueeze(维度的增加/减少) ▪ Transpose/t/permute(维度交换) ▪ Expand/repeat(维度的扩展) # view/reshape 这两个API,都是通用的a.reshape()和a.vie 阅读全文
posted @ 2023-07-30 19:01 lipu123 阅读(140) 评论(0) 推荐(0)
摘要:# indexing ``` a=torch.randn(4,3,28,28) a[0].shape # torch.Size([3, 28, 28]) a[0,0].shape # torch.Size([28, 28]) a[0,0,2,4] # tensor(0.6574) ``` # sel 阅读全文
posted @ 2023-07-30 16:15 lipu123 阅读(64) 评论(0) 推荐(0)
摘要:# Import from numpy >torch.from_numpy(data) ``` a=np.array([2,3.3]) a #array([2. , 3.3]) torch.from_numpy(a) #tensor([2.0000, 3.3000], dtype=torch.flo 阅读全文
posted @ 2023-07-30 10:51 lipu123 阅读(34) 评论(0) 推荐(0)
摘要:python和pytorch中的类型对比: 我们可以发现pytorch中每中类型后面都有一个Tensor。 ![image](https://img2023.cnblogs.com/blog/1914163/202307/1914163-20230729211210389-1808416709.pn 阅读全文
posted @ 2023-07-29 22:40 lipu123 阅读(72) 评论(0) 推荐(0)
摘要:# 1 常用的数据结构 ![image](https://img2023.cnblogs.com/blog/1914163/202306/1914163-20230613200428448-929868858.png) ![image](https://img2023.cnblogs.com/blo 阅读全文
posted @ 2023-06-13 20:45 lipu123 阅读(41) 评论(0) 推荐(0)