一、直接对CEloss赋予权重 一定要把loss的权重放到GPU上,要不然会报错。其中[0.2, 0.15, 0.15, 0.5]就是对于我要区分的四类赋予的权重。 weights = torch.tensor([0.2, 0.15, 0.15, 0.5]).to(device