YouTip LogoYouTip

Pytorch Torch Argmax

# PyTorch torch.argmax Function * * Pytorch torch Reference Manual](#) `torch.argmax` is a function in PyTorch used to return the index of the maximum value along a dimension. ### Function Definition torch.argmax(input, dim, keepdim) * * * ## Usage Example ## Example import torch x = torch.tensor([[1,3,2],[4,1,3]]) # Index of the global maximum print("Global maximum index:", torch.argmax(x)) # Along dim=0 Index of maximum value print("dim=0 Maximum index:", torch.argmax(x, dim=0)) # Along dim=1 Index of maximum value print("dim=1 Maximum index:", torch.argmax(x, dim=1)) The output result is: Global maximum index: tensor(4) dim=0 Maximum index: tensor([1, 0, 1]) dim=1 Maximum index: tensor([1, 0]) * * Pytorch torch Reference Manual](#)
← Pytorch Torch AtanhPytorch Torch Arcsin β†’