all AI news
min(), max(), aminmax(), amin(), amax(), argmin() and argmax() in PyTorch
April 14, 2024, 12:17 a.m. | Super Kai (Kazuya Ito)
DEV Community dev.to
min() can get one or more minimum values as shown below:
*Memos:
min() can be called both from torch and a tensor.- Setting a dimension(dim) to the 2nd argument with torch or the 1st argument with a tensor gets zero or more 1st minimum values and the indices of them.
import torch
my_tensor = torch.tensor([[5, 4, 7, 7],
[6, 5, 3, 5],
[3, 8, 9, 3]])
torch.min(my_tensor)
my_tensor.min()
# tensor(3)
torch.min(my_tensor, 0)
my_tensor.min(0)
torch.min(my_tensor, -2)
my_tensor.min(-2)
# torch.return_types.min(
# values=tensor([3, …
aminmax argmin max memos min pytorch tensor them torch values
More from dev.to / DEV Community
Jobs in AI, ML, Big Data
Data Architect
@ University of Texas at Austin | Austin, TX
Data ETL Engineer
@ University of Texas at Austin | Austin, TX
Lead GNSS Data Scientist
@ Lurra Systems | Melbourne
Senior Machine Learning Engineer (MLOps)
@ Promaton | Remote, Europe
C003549 Data Analyst (NS) - MON 13 May
@ EMW, Inc. | Braine-l'Alleud, Wallonia, Belgium
Marketing Decision Scientist
@ Meta | Menlo Park, CA | New York City