Hi Rishav!



 Rishav_Sen:

When I run the model before training, the values in the output_from_model are different for each row, so I now that the training is the source of error.


You had mentioned above that your training set is highly unbalanced.
You didn’t post a complete row from your all-identical
output_from_model rows:
[-2.9972, -2.9940, -3.0171,  ...,  6.3018, -2.9989, -3.0200]

but if I imagine that the three elided entries have values all about
-3.0, then it looks like you are predicting the class that corresponds
to index 8 (starting from 0) with high certainty.  Is the class that is
highly over-represented in your unbalanced data set class 8 (starting
from 0)?
In code posted above, you calculate weight, presumably to reweight
your unbalanced data, but you don’t show where (or even if) you
perform this reweighting.
Can you reproduce this issue with randomly-generated (balanced)
data?  If so, please post a complete, runnable script (without any
extraneous stuff such as Dataloader) that illustrates your issue.
Can you reproduce this issue training on a perfectly-balanced subset
of your training data (without any reweighting)?
Best.
K. Frank