Python 有没有办法得到多维张量上的torch.mode
torch.mode是否可以应用于多个维度 比如说Python 有没有办法得到多维张量上的torch.mode,python,numpy,machine-learning,pytorch,Python,Numpy,Machine Learning,Pytorch,torch.mode是否可以应用于多个维度 比如说 import numpy as np import torch x = np.random.randint(10, size=(3, 5)) y = torch.tensor(x) 假设y有 [[6 3 7 3 0] [2 5 7 9 7] [6 1 4 6 3]] torch.mode应返回大小为3的张量[3,7,6] 在不使用循环的情况下使用torch中的“维度”属性来选择应使用模式运算符减少的维度 torch.mode(y, di
import numpy as np
import torch
x = np.random.randint(10, size=(3, 5))
y = torch.tensor(x)
假设y有
[[6 3 7 3 0]
[2 5 7 9 7]
[6 1 4 6 3]]
torch.mode
应返回大小为3的张量[3,7,6]
在不使用循环的情况下使用torch中的“维度”属性来选择应使用模式运算符减少的维度
torch.mode(y, dim = 1)[0]
将为您提供所需的答案。如果您在示例中使用
torch.mode
,您将得到您想要的答案。你能再举一个例子吗?