1. 程式人生 > 其它 >pytorch中torch.max函式

pytorch中torch.max函式

技術標籤:pythonpytorch

torch.max(x,0)返回每一列中最大值的那個元素,且返回索引(返回最大元素在這一列的行索引)。torch.max(x,1)返回每一行中最大值的那個元素,且返回索引。
如下面程式輸出結果如圖:

x = torch.randn(5,5)
print(x)
print(torch.max(x,0))
print(torch.max(x,1))

在這裡插入圖片描述