That’s ok . For CrossEntropy, it’s straightforward: provide a tensor of shape [C]( C is the number of classes, and the id of the classes ranges from [0, C) ). Each value represent the weight of each class, the weight here should be positive. For example:
from torch import nn
import torch as tc
num_cls = 100
weights = tc.rand([num_cls])
loss = nn.CrossEntropyLoss(weight = weights)