Torch.max() - Get two highest values

I want to get the two highest values from a number. I am thinking of getting the max, removing it, and then get the max again. Does anyone have a link to the code implementation for this function?

Thank you in advance

Hi Maria!

Does torch.topk() do what you want? I would expect it to be the most
efficient approach.

Good luck.

K. Frank

2 Likes

Amazing! Thank you so much!