Is there a way to get max and argmax by one stroke ?
import numpy as np
a=[0,0,1,0]
maximum=max(a)
index=np.argmax(a)
Is there a fastest way to do it, with something like:
[maximum,index]=function(a)
Maybe something like this is faster...
index = np.argmax(a)
maximum = a[index]
pytorch
is more elegant thannumpy
:torch.tensor([0,0,1,0]).max(0)
givestorch.return_types.max(values=tensor(1),indices=tensor(2))