Solved by Latope2-150 in post #5 
              
              
                This error means that your input and target in your loss function do not have the same sizes at dimension 0, i.e. the mini-batch sizes are different.