Hi, I have an issue with slicing a numpy array with a tensor of one element. For example:
In [1]: import torch
In [2]: torch.__version__
Out[2]: '2.4.0+cu121'
In [3]: import numpy as np
In [4]: np.__version__
Out[4]: '2.0.2'
In [5]: a = np.random.normal(size=(3, 4))
In [6]: a
Out[6]:
array([[-0.03374389, -2.06199934, 0.22114562, -0.10317616],
[-1.40243768, -0.86554835, 0.49141156, 1.49605485],
[ 2.05006526, -1.18818391, 0.61184828, 1.82132413]])
In [7]: torch_idx = torch.tensor([1])
In [8]: np_idx = np.array([1])
In [9]: a[:, torch_idx]
Out[9]: array([-2.06199934, -0.86554835, -1.18818391])
In [10]: a[:, np_idx]
Out[10]:
array([[-2.06199934],
[-0.86554835],
[-1.18818391]])
I would expect that both methods would return a (3, 1) column but it seems that slicing with a torch tensor returns a (3, ) row. I was wondering if this is intentional and why is it like this?