Solved by ptrblck in post #10 
              
              
                In that case, your shapes should be [batch_size, seq_length, nb_classes]. 
Try to permute your ourput using output = output.permute(1, 0, 2) and squeeze the additional dimension in your target target = target.squeeze(2). 
Where does dim2 in your target come from?