I ran into a strange problem. I am trying out a GRU with pytorch. My forward function goes like this: def forward(self, ids, lengths, masks, labels): … Everything works fine until it gets a batch containing only 1 element. I inserted a print for debugging at the very beginning of the forward function: print(“FORW”, masks, lengths), and the output is FORW tensor() tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]). I.e. lenghts refers to masks and masks refers to lengths? Any idea why this happens?
Could you post an executable code snippet to reproduce this issue using a single sample?
You can post code snippets by wrapping them into three backticks ```, which makes debugging easier.