首页 > 编程知识 正文

pytorch view,耐克torch4

时间:2023-05-05 03:07:29 阅读:59601 作者:1095

max和argmax的名字看起来很相似,但差别很大

max_num,index=Torch.max(Tensor,dim=? 返回指定维的最大数量及其索引,如下所示

b=torch.tensor ([ [ 3,2 ],[ 1,4 ],[ 5,6 ],[ 7,8 ] ] ) print(b ) b ) max_num,index=torch.max(b

输出:

tensor ([ [ 3,2 ],[ 1,4 ] ],[ [ 5,6 ],[ 7,8 ] ] ) * * * * * * * * * * * * * * * * * * * * * * * * *。

b=torch.tensor ([ [ 3,2 ],[ 1,4 ],[ 5,6 ],[ 7,8 ] ] ) print(b ) b ) print('*'*50 )索引=torch

输出:

输出: tensor ([ [ 3,2 ],[ 1,4 ] ],[ [ 5,6 ],[ 7,8 ] ] ) * * * * * * * * * * * * * * * * * * * * * * * *。

torch.min

b=torch.tensor ([ [ 3,2 ],[ 1,4 ],[ 5,6 ],[ 7,8 ] ] ) min_num,index=torch.min(b ) b,dim=1

输出:

tensor ([ [ 3,2 ],[ 1,4 ] ],[ [ 5,6 ],[ 7,8 ] ] ) * * * * * * * * * * * * * * * * * * * * * * * * *。

torch.argmin

b=torch.tensor ([ [ 3,2 ],[ 1,4 ],[ 5,6 ],[ 7,8 ] ] )索引=torch.arg min (b ) b,dim=1)打印(b

输出:

tensor ([ [ 3,2 ],[ 1,4 ] ],[ [ 5,6 ],[ 7,8 ] ] ) * * * * * * * * * * * * * * * * * * * * * * * * *。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。