Solved by ptrblck in post #4 
              
              
                Your target should contain class indices in the range [0, nb_classes-1]. 
In your case this would be [0, 23]. 
To debug this issue, you could add a print statement and check, which target batch fails this assumption.