
正文
Pytorch 一些函数用法
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
PyTorch中view的用法:https://blog.csdn.net/york1996/article/details/81949843
max用法
import torch d=torch.Tensor([[,],[,]])
print(d)
tensor([[1., 3.],
[2., 4.]])
import torch d=torch.Tensor([[,],[,]])
print(torch.max(d,))
print(torch.max(d,))
(tensor([2., 4.]), tensor([1, 1]))
(tensor([3., 4.]), tensor([1, 1]))
torch.max()返回两个结果,第一个是最大值,第二个是对应的索引值;第二个参数 0 代表按列取最大值并返回对应的行索引值,1 代表按行取最大值并返回对应的列索引值。





