Issue
I am trying to get used to Pytorch indexing. However I couldn't understand the difference between tensor[:,-1] (which should print the last column) and tensor[...,-1] which is printing different output (output2)
import torch
tensor = torch.rand([3,3,3,3])
print('Output1')
print(tensor[:,-1])
print('Output2')
print(tensor[...,-1])
Solution
It looks like the following indices are equivalent
tensor[:, -1] == tensor[:, -1, :, :]
tensor[..., -1] == tensor[:, :, :, -1]
Answered By - MaryRa
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.