Your interpretation is correct, that is how the class weights will work with CrossEntropyLoss.
There’s a little more detail on the docs on how this is done: http://pytorch.org/docs/master/nn.html?highlight=nll%20loss#torch.nn.NLLLoss 6.9k