Ah, OK. But hidden_size is not data dependent, and you can set to any other value – I was actually surprised it’s 121 when most people go four round values (e.g., 50, 100, 200) or powers of 2 (e.g., 64, 128, 256, 512).
Either way, output = output.view(121, -1, 40) seem off. It kind of implies that you don’t know your batch_size but have to infer it with -1. This can’t be right :).