Hi protoneqt!



 protoneqt:

But it should return tensor([[1, 1], [1, 1]], dtype=torch.int32). How do I make it to return this result?


I’m not sure exactly what you want or are expecting.  But maybe the following
helps answer your question:
>>> torch.__version__
'1.7.1'
>>> dist = torch.arange (30).reshape ((5, 6))
>>> dist
tensor([[ 0,  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, 28, 29]])
>>> dist[[1, 2], [3, 4]]
tensor([ 9, 16])
>>> dist[1:3, 3:5]
tensor([[ 9, 10],
        [15, 16]])

I would call dist[[1, 2], [3, 4]] indexing and dist[1:3, 3:5] slicing,
but I’m not really sure what the proper terminology is.
Best.
K. Frank