What is the exact reason for treating tensors and (numpy) arrays differently for indexing of tensors? For example:
indices = torch.tensor([[0, 1], [0, 2]])
t = torch.arange(1,28).reshape(3,3,3)
# tensor([[[ 1, 2, 3],
# [ 4, 5, 6],
# [ 7, 8, 9]],
# [[10, 11, 12],
# [13, 14, 15],
# [16, 17, 18]],
# [[19, 20, 21],
# [22, 23, 24],
# [25, 26, 27]]])
>>> a[indices.numpy()]
tensor([[ 1, 2, 3],
[16, 17, 18]])
>>> a[indices]
tensor([[[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]],
[[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[19, 20, 21],
[22, 23, 24],
[25, 26, 27]]]])
I understand how it works, but is there a particular reason for this? Isn’t having this differentiation a little bit confusing and potentially can lead to errors?