I’ve finally got it working, and all I needed was to change the encoder forward function. Turns out the problem was in fact the line where I was trying to concatenate the hidden state of the encoder. I’ve replaced it with your flatten function and it works great. Thanks again!