- 博客(4)
- 收藏
- 关注
原创 PyTorch 3.1 Tensor笔记
Tensor 创建Tensor a = t.Tensor(2,3) # 指定形状 a.tolist() # 转为list a.size() # 返回size,与shape等价,torch.Size([2, 3]) a.numel() # 元素总个数 b = t.tensor([2,3]) # tensor([1,2]), torch.Size([2]) 常用tensor操作 函数名以_结尾的都是inplace方式, 即会修改调用者自己的数据。 a = t.arange(0, 6) a.view(2,3)
2022-04-26 16:36:24
1072
原创 PyTroch 3.2 autograd笔记
Autograd requires_grad & 计算图 如果需要计算某个Tensor的导数 ,则需要将其requires_grad设置为True variable默认是不需要求导的,即requires_grad属性默认为False,如果某一个节点requires_grad被设置为True,那么所有依赖它的节点requires_grad都为True variable的volatile属性默认为False,如果某一个variable的volatile属性被设为True,那么所有依赖它的节点volati
2022-04-26 16:35:02
90
原创 PyTorch中gather的理解
2维tensor的gather操作理解 考虑2维tensor a a = t.arange(0, 16).view(4, 4) print(a) output: tensor([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) index与[[2,2,0,1]]的维度相同,即(1,4). dim=0,按列查看,第一个2处于该张量的第0列 ,所以第一个元素取a中第
2022-04-02 18:45:55
1411
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人