首页 > 其他分享 >torch.argmax()函数-截至2023年8月28日

torch.argmax()函数-截至2023年8月28日

时间:2023-08-28 10:01:38浏览次数:47  
标签:dim 10 argmax torch 28 索引 print

argmax函数参数dim=0表示从列获取最大值索引,dim=1从行获取最大值索引,dim=-1从最后一个维度获取最大值索引[1]

举例

import torch
d = torch.tensor([[9,7,6],
				[4,8,2],
                 [5,10,0]])
print(torch.argmax(d , dim=0))#结果应为9,10,6的所在列的索引==》0,2,0
print(torch.argmax(d , dim=1))#结果应为9,8,10所在行的索引==》0,1,1
print(torch.argmax(d , dim=-1))#结果应为9,8,10所在行的索引==》0,1,1

运行结果

image-20230826153122554


  1. https://blog.csdn.net/weixin_42494287/article/details/92797061 ↩︎

标签:dim,10,argmax,torch,28,索引,print
From: https://www.cnblogs.com/urname/p/17661485.html

相关文章