728x90
반응형

NumPy 의 ndarray에서
np.max 와 np.min 함수를 이용하여 최대, 최소인 값을 구함.
특정 축을 axis parameter로 지정하여 구할 수 있음 (결과는 해당 axis가 1이 됨.)np.argmax 와 na.argmin 함수를 이용하여 최대, 최소인 값의 index를 반환함.
PyTorch 의 tensor 에서
torch.max와 torch.min 함수를 사용하여 최대값과 최소값을 구함.
- 특정 축을
dimparameter로 지정하여 구할 수 있음 (결과는 해당 축이 1이 됨.). - 특정 축을 지정할 경우,
torch.max와torch.min은 indices를 같이 반환함.torch.argmax와torch.argmin함수를 이용하여 최대, 최소값의 indices를 반환함.
# 다음은 3x2 tensor에서의 결과로 참고할 것.
# a=[[0.69393307 0.6414582 ]
# [0.12864423 0.11370805]
# [0.6533455 0.8534571 ]]
>>> torch.max(a,1)
torch.return_types.max(
values=tensor([0.6939, 0.1286, 0.8535]),
indices=tensor([0, 0, 1]))
TensorFlow 의 tensor 에서
tf.reduce_max와 tf.reduce_min 함수를 사용하여 최대값과 최소값을 구함.
- 특정 축을 따라 구할 경우엔,
axisparameter로 지정함 (결과는 해당 축이 1이 됨.).
torch.argmax 와 torch.argmin 함수를 이용하여 최대, 최소값의 indices를 반환함.
같이 보면 좋은 자료들
https://gist.github.com/dsaint31x/a70c4ced5d5929b47d5725214fbee616
dl_tensor_max_min_argmax_argmin.ipynb
dl_tensor_max_min_argmax_argmin.ipynb. GitHub Gist: instantly share code, notes, and snippets.
gist.github.com
https://dsaint31.tistory.com/216
NumPy : sum, mean, std, and so on
영상이나 텐서를 처리할 때, 각 pixel intensity 나 각 요소에 대해 다양한 통계처리가 필요함.NumPy는 자체적으로 다양한 통계처리 함수들 (집계함수, 또는 Aggregation Function 이라고 불림) 을 제공함. 참
dsaint31.tistory.com
728x90
'Python' 카테고리의 다른 글
| [DL] Tensor: Random Tensor 만들기 (NumPy, PyTorch) (0) | 2024.03.29 |
|---|---|
| [DL] Define and Run vs. Define by Run (0) | 2024.03.28 |
| [Python] Enum (열거형, Enumeration Type) (0) | 2024.03.24 |
| [OOP] Example: MObject, Point, and Class (0) | 2024.03.23 |
| [DL] PyTorch: Autograd (Basic) (1) | 2024.03.22 |