深度学习与PyTorch入门实战 - 14. Tensor高阶where(cond>0.5, a, b) 14 Out[203]: 15 tensor([[0., 0.], 16 [0., 1.]]) ## gather torch.gather(input, dim, index, out=None) → Tensor Gathers values along an axis specified by dim. For a 3-D Out\[217]: tensor(\[100, 101, 102, 103, 104, 105, 106, 107, 108, 109])|| |19|| |20 In \[220]: torch.gather(label.expand(4,10), dim=1, index=idx.long())|| |21 tensor(\[\[107, 104, 109], \[107, 104, 109]0 码力 | 8 页 | 501.85 KB | 2 年前3
Facebook -- TVM AWS Meetup Talksize=(K,)).type(torch.int64) index = index[:, None].expand(index.shape[0], input.shape[1]) out = torch.gather(input, 0, index) input_ph = torch_placeholder(input, dynamic=True) index_ph = torch_placeholder(index0 码力 | 11 页 | 3.08 MB | 1 年前3
【PyTorch深度学习-龙龙老师】-测试版202112的实现如下: In [51]: x = torch.randint(0, 9, [2, 3, 4]) # 随机生成成绩张量 print('x:', x) out = torch.gather(x, dim=2, index=idx) # 在科目维度上采集数据 print('out:', out) Out[51]: # 成绩张量 x: tensor([[5,0 码力 | 439 页 | 29.91 MB | 2 年前3
共 3 条
- 1













