Pytorch:explain torch.argmax

Pytorch:explain torch.argmax,pytorch,torch,torchvision,Pytorch,Torch,Torchvision,您好,我有以下代码: import torch x = torch.zeros(1,8,4,576) # create a 4 dimensional tensor x[0,4,2,333] = 1.0 # put on 1 on a random spot # I want to find the index of the highest value (0,4,2,333) print(x.argmax()) # this should return the index 这是回报 张量(1

您好,我有以下代码:

import torch
x = torch.zeros(1,8,4,576) # create a 4 dimensional tensor
x[0,4,2,333] = 1.0 # put on 1 on a random spot

# I want to find the index of the highest value (0,4,2,333)
print(x.argmax()) # this should return the index
这是回报

张量(10701)

这10701有什么意义


如何获取实际索引0,4,2333?

四维数组中的数据线性存储在内存中,并且
argmax()
返回此平面表示的相应索引

Numpy具有分解索引的功能(从平面数组索引转换为相应的多维索引)

将numpy导入为np
np.Unlavel_指数(10701,(1,8,4576))