Compute weight for CrossEntropyLoss function

Hi, I want to use the weight parameter while calculating the loss. I want to know how to supply the weights, for example, I have a batch of 32 and there are 6 classes, now I have a tensor of size 6 that contains the number of occurrences of each class in the batch. I want to know, how to compute the weight value for each class.


A common approach is to calculate the weights based on the class frequencies from the entire training dataset instead of recomputing it for each batch.

Okay, so I calculated the frequency distribution for the training data, now how do I calculate the weights?