pytorch之max()函数
原文链接:https://blog.youkuaiyun.com/liuweiyuxiang/article/details/84668269
形式: torch.max(input) → Tensor
返回输入tensor中所有元素的最大值:
a = torch.randn(1, 3)
>>0.4729 -0.2266 -0.2085
torch.max(a) #也可以写成a.max()
>>0.4729
形式: torch.max(input, dim, keepdim=False, out=None) -> (Tensor, LongTensor)
按维度dim 返回最大值,并且返回索引。torch.max(a,0)返回每一列中最大值的那个元素,且返回索引(返回最大元素在这一列的行索引)。返回的最大值和索引各是一个tensor,一起构成元组(Tensor, LongTensor)
本文介绍了pytorch中max()函数的使用。torch.max(input)可返回输入tensor中所有元素的最大值;torch.max(input, dim, keepdim=False, out=None)则按维度dim返回最大值及索引,返回的最大值和索引构成元组。

326

被折叠的 条评论
为什么被折叠?



