VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > 简明python教程 >
  • gather函数(2)

1
官方文档:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
torch.gather(input, dim, index, out=None) → Tensor
 
 Gathers values along an axis specified by dim.
 
 For a 3-D tensor the output is specified by:
 
 out[i][j][k] = input[index[i][j][k]][j][k] # dim=0
 out[i][j][k] = input[i][index[i][j][k]][k] # dim=1
 out[i][j][k] = input[i][j][index[i][j][k]] # dim=2
 
 Parameters:
 
  input (Tensor)-The source tensor
  dim (int)-The axis along which to index
  index (LongTensor)-The indices of elements to gather
  out (Tensor, optional)-Destination tensor
 
 Example:
 
 >>> t = torch.Tensor([[1,2],[3,4]])
 >>> torch.gather(t, 1, torch.LongTensor([[0,0],[1,0]]))
  1 1
  4 3
 [torch.FloatTensor of size 2x2]

相关教程