Index 599 is out of bounds for dimension 0 with size 10

Hello,

I am getting this error
out = torch.gather(v,0,t).float()
RuntimeError: index 599 is out of bounds for dimension 0 with size 10

Any suggestion on what to do?

The gather operation fails since t contains an invalid index (599) related to the size of dim0 of v (10). Here is a small example code showing the issue:

v = torch.randn(10)
print(v)
# tensor([ 1.1481,  1.1344,  0.7485,  0.7008, -1.4947,  0.0202,  1.0304, -0.6202,
#         -0.6328,  1.1113])

# works since 0 is a valid index
t = torch.tensor([0])
out = torch.gather(v,0,t).float()
print(out)
# tensor([1.1481])

# fails since 599 is invalid
t = torch.tensor([599])
out = torch.gather(v,0,t).float()
# RuntimeError: index 599 is out of bounds for dimension 0 with size 10

thank you for your response! much appreciated