Solved by jpeg729 in post #2 
              
              
                Your LSTM isn’t initialised with the batch_first=True option, therefore it expects the batch dimension to be the second dimension. Whereas memory.sample() makes batches by concatenating along a new first dimension. That doesn’t answer your current question, but I think it needs checking. 
Now, to an…