기술공부/파이토치

torch.max

넹넹선생님 2024. 8. 1. 22:41
728x90
반응형

torch.max(input, dim, keepdim=False, *, out=None)

 

매개변수

  • 입력 ( 텐서 ) - 입력 텐서.
  • dim ( int ) – 줄일 차원.
  • keepdim ( bool ) – 출력 텐서가 dim유지되었는지 여부. 기본값: False.

키워드 인수

out ( 튜플 , 선택 사항 ) – 두 개의 출력 텐서(max, max_indices)의 결과 튜플

 

ex.

a = torch.randn(4, 4)

a

tensor([[-1.2360, -0.2942, -0.1222,  0.8475],
        [ 1.1949, -1.1127, -2.2379, -0.6702],
        [ 1.5717, -0.9207,  0.1297, -1.8768],
        [-0.6172,  1.0036, -0.6060, -0.2432]])


torch.max(a, 1)

torch.return_types.max(values=tensor([0.8475, 1.1949, 1.5717, 1.0036]), indices=tensor([3, 0, 0, 1]))

 

 

참고 문서: https://pytorch.org/docs/stable/generated/torch.max.html

728x90
반응형

'기술공부 > 파이토치' 카테고리의 다른 글

mac M1, M2에서 GPU  (0) 2024.04.17
.view(), .reshape()  (0) 2022.10.24