jrepo:

weights = [0.2, 0.2, 0.4, 0.4]


Can you elaborate a bit on how you calculate the weights?



 jrepo:

weights = [0.2, 0.2, 0.4, 0.4]

but to the loss functions I should pass them as
weights = [0.4, 0.2, 0.4, 0.4]



Also, both the weights lists are different here.
Basically, the weights list has length = number of total classes. (Not the number of samples)
weights[i] = weight calculated for class i.
I am not sure how your example relates to this definition. Maybe I am a bit confused with your example.