Pytorch 一些函數用法


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 代表按行取最大值並返回對應的列索引值。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM