Hi,
I just wanted to ask how the mechanism of passing the weights to CrossEntropyLoss works. Currently, I have a list of class labels that are [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].
I create the loss function in the init and pass the weights to the loss:
weights = [0.5, 1.0, 1.0, 1.0, 0.3, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
class_weights = torch.FloatTensor(weights).cuda()
self.criterion = nn.CrossEntropyLoss(weight=class_weights)

Then in the update step, I pass the labels of my current batch to the loss function:
self.model.train()
self.optimizer.zero_grad()
logits, _ = self.model(inputs)
loss = self.criterion(logits, labels)

Now the labels can be something like this: [2, 4, 2, 1, 0, 4, 5]
So, since the weights are passed as a list, will they be automatically mapped to the current labels passed? like so:  [2: 1.0, 4: 0.3,  2: 1.0, 1: 1.0, 0: 0.5, 4: 0.3, 5: 1.0]?
The reason I am asking this is that I would be much more comfortable passing a dictionary of weights to the loss function, instead of a list. So that I am sure the weights are mapped to the proper classes. Can someone elaborate on the way weights are passed to the loss function here?