码迷,mamicode.com
首页 > 其他好文 > 详细

Pytorch 一些函数用法

时间:2018-08-29 14:16:37      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:max   view   第一个   用法   int   tps   参数   sdn   port   

PyTorch中view的用法:https://blog.csdn.net/york1996/article/details/81949843

max用法

import torch

d=torch.Tensor([[1,3],[2,4]])
print(d)

tensor([[1., 3.],
        [2., 4.]])

import torch

d=torch.Tensor([[1,3],[2,4]])
print(torch.max(d,0))
print(torch.max(d,1))

(tensor([2., 4.]), tensor([1, 1]))
(tensor([3., 4.]), tensor([1, 1]))

torch.max()返回两个结果,第一个是最大值,第二个是对应的索引值;第二个参数 0 代表按列取最大值并返回对应的行索引值,1 代表按行取最大值并返回对应的列索引值。

Pytorch 一些函数用法

标签:max   view   第一个   用法   int   tps   参数   sdn   port   

原文地址:https://www.cnblogs.com/cunyusup/p/9552555.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!