Difference between numpy.argsort and torch.argsort

Viewed 447

I have checked argsort function of pytorch and numpy are same by definition.

However, when I use those functions along different size of random tensor(or ndarray), It makes difference. I have no idea why this difference is observed.

Example code:

enter image description here

and results below,

enter image description here

1 Answers

... in general, the actual implementation will vary with data type.

From the numpy docs. Since PyTorch tensors are 32bit float precision by default, and numpy arrays 64 bit, the behaviour is not guaranteed to be consistent.

Related