I want to feed part of the model’s output to auxiliary loss.
With it Im getting the error
x = torch.rand(32, 128, 1000)
lens = torch.randint(0, 1000, (32,))
mask_start = (torch.rand(32) * (lens - 64)).long()
x[:,:,mask_start:mask_start+64]
TypeError: only integer tensors of a single element can be converted to an index
Well, i would not use loops in tensors.
Seems like torch.gather is thing i need.
But not sure how to generate tensor with all indeces i need.
Like if mask start at 10 and ends at 74, i should have tensor with 10,11,12… 73, 73.