PyTorch

PyTorch: torch.max

  • torch.max(input) --> (Tensor)

返回input中的最大值

#torch.max(input) --> (Tensor)
a = torch.rand(1, 3, 5)
>>tensor([[0.4086, 0.7224, 0.5559]])
 
torch.max(a)
>>tensor(0.7312)
  • torch.max(input, dim, keepdim=False, out=None) -> (Tensor, LongTensor)
    当dim!=None, 返回在dim维度上的最大值和最大值的索引
a = torch.randn(3, 5)
print(a)
>>tensor([[ 1.2639,  0.9473,  0.3617, -0.1861,  0.1839],
          [-0.0825, -0.4322, -0.1637,  1.1394, -0.7880],
          [-0.3071, -0.8307,  0.2513, -0.0020,  0.0868]])
max, max_idx = torch.max(a, 1)
print('max={}\n\nmax_idx={}'.format(max, max_idx))
>>max=tensor([1.2639, 1.1394, 0.2513])

  max_idx=tensor([0, 3, 2])
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值