Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 有没有办法得到多维张量上的torch.mode_Python_Numpy_Machine Learning_Pytorch - Fatal编程技术网

Python 有没有办法得到多维张量上的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

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, dim = 1)[0]

将为您提供所需的答案。

如果您在示例中使用
torch.mode
,您将得到您想要的答案。你能再举一个例子吗?