Artificial intelligent assistant

pytorchの関数gatherの処理内容について pytorch`gather` **Example** `t` **Example:** >>> t = torch.tensor([[1,2],[3,4]]) >>> torch.gather(t, 1, torch.tensor([[0,0],[1,0]])) tensor([[ 1, 1], [ 4, 3]]) `dim = 0`t tensor([[1, 2], [3, 2]]) **** <

3D
2Dkok


out[i][j] = input[index[i][j]][j] # if dim == 0
out[i][j] = input[i][index[i][j]] # if dim == 1






#dim==0 indexinputoutput
#inputoutput
input
1 2
3 4

index
0 0
1 0

output #output
1 2 #input[0][0] input[0][1]
3 2 #input[1][0] input[0][1]

#dim==1 indexinputoutput
#inputoutput
input index output #output
1 2 0 0 1 1 #input[0][0] input[0][0]
3 4 1 0 4 3 #input[1][1] input[1][0]

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 2116b4445e28a6e8553db680287d8a26