Pytorch take in the index tensor There are many ways, such as index_select and masked_select, and gt, ge, etc. with the food, but if you need to remove the minimum or maximum number of several tensor index, you need to write about hands
a = torch.tensor([2,3,1,5]) y,_ = torch.sort(a) mask = a.gt(y[0]) index = [] mask_list = (mask== False).nonzero() index = [int(i) for i in mask_list] index >>>[2]
Do first sort tensor, and obtaining the original sheet is greater than the minimum and less than or equal y [0] of the mask is greater than is True, less than or equal to False, then nonezero () method can be used to obtain mask False the index, done