PyTorch F.cross_entropy报错: RuntimeError: 1D target tensor expected, multi-target not supported
原因cross_entropytarget参数只需要标签即可,不需要传one-hot向量代码试验传入one-hot向量报错importtorchimporttorch.nn.functionalasFa=torch.Tensor([[0,0,1],[1,0,0]]).long()b=torch.Tensor([[0.8,0.1,0.1],[0.9,0.05,0.05]])print(F.cross