js_reverse/ayf_ocr/02pytorch基础语法/张量求最大值.py
2023-05-26 13:34:28 +08:00

18 lines
242 B
Python

import torch
list_7 = [
[792, 436, 928, 303],
[809, 170, 778, 652],
[967, 520, 419, 184]
]
t7 = torch.tensor(list_7)
# 求最大值
print(t7.max())
# 列求最大值
print(t7.max(dim=0))
# 行求最大值
print(t7.max(dim=1))