测试了文献资料的nn.CrossEntropyLoss示例。似乎不起作用。
loss = nn.CrossEntropyLoss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.randn(3, 5).softmax(dim=1)
output = loss(input, target)
print(output)错误:
RuntimeError: 1D target tensor expected, multi-target not supported发布于 2022-05-10 19:52:05
您可能需要升级您的火炬版本。
pip install torch --upgradehttps://stackoverflow.com/questions/72191924
复制相似问题