I didn’t mean to give importance to batch_size in my previous reply. The issue is that the input to self.fc1 is supposed to be (batch_size, seq_length * embed_dim) and output would be (batch_size, latent_dim). From what I understood from your answer, my input will be (batch_size, seq_length, embed_dim)  shaped tensor and output will be a (batch_size, seq_length, latent_dim) shaped tensor, which is different from what I wanted.