CarlosHernandezP:

Is there a simple way to get this weight value for each sample knowing the ammount of samples of each class?


You would need to get the target tensor beforehand to be able to create the weights for each sample.
This can be done offline before training e.g. by iterating the Dataset once.



 CarlosHernandezP:

I could not reproduce your sample code for my 9 class example.


What errors/issues are you seeing?