suddenly, my model gave IndexError target 4 out of bounds
but as you told i have  n_bclasses = [1,2,3,4]
and I put output_size of linear layer n_bclasses - 1 gave error as mention
but giving n_bclasses +1 i.e 5 works, Any reason for that .
Thanks
update: Problem has been solved  , but weirdly, I have to go to dataframe and minus by one so that it become [0,1,2,3] , then just passing nb_classes to Linear layer,strangely