
torch
hetangx
这个作者很懒,什么都没留下…
展开
-
pytorch中.cuda()和.to(device)有区别吗
参考官方文档https://pytorch.org/docs/stable/notes/cuda.html在如下的示例代码中:with torch.cuda.device(1): # allocates a tensor on GPU 1 a = torch.tensor([1., 2.], device=cuda) # transfers a tensor from CPU to GPU 1 b = torch.tensor([1., 2.]).cuda()原创 2020-07-23 14:13:39 · 17241 阅读 · 7 评论 -
学习记录——pytorch里的gather方法
torch.gather(input, dim, index)设tt=torch.tensor([[1, 2], [3, 4]]),index=torch.tensor([[0, 0], [1, 0]])tt和index可写为tensor([[1, 2], [3, 4]])tensor([[0, 0], [1, 0]])1.当dim=1...原创 2019-10-25 16:54:22 · 206 阅读 · 0 评论