Welcome !
Instead of the #resize line, I’ve used :
def forward(self, x, length):
      x = torch.narrow(0,0,length) #this line instead of the resize line in the previous forward code
      x = self.conv1(x)

And it raises the error : narrow(): argument ‘length’ (position 4) must be int, not Tensor
Further analysis showed that ‘length’ is my 512 x 1 tensor with the 512 different lengths (512 being the batch size).
I would like to apply the narrow function to each sequence, so that each sequence is “narrowed” by it’s corresponding length in the length vector.
Thanks for your time,