1、版本:
dist-packages/torch/nn/_reduction.py:43: UserWarning: size_average and reduce args will be deprecated, please use reduction='none' instead.
warnings.warn(warning.format(ret))
修改:
# loss = nn.functional.cross_entropy(logits.view(-1, logits.size(-1)), golden.view(-1), reduce=False)
loss = nn.functional.cross_entropy(logits.view(-1, logits.size(-1)), golden.view(-1), reduction='none')
即可解决。