在使用torch.nn.CrossEntropyLoss时,其中有个参数是weight,官方给出的文档中显示,weight是a manual rescaling weight given to each class,也就是一个缩放的尺度。但我发现,当另一个参数的reduction为mean的时候,会出现一些问题。
import torch
import torch.nn
pred = torch.tensor([[1,5],[2,2]]).float()
label = torch.tensor