1. loss函数
https://pytorch.org/docs/stable/nn.html#loss-functions
torch.nn.CrossEntropyLoss(weight=None, size_average=True, ignore_index=-100, reduce=True)
参数:
weight (Tensor, optional) – a manual rescaling weight given to each class. If given, has to be a Tensor of size C
size_average (bool, optional) : False - sum of mibi-batch; True - average of mibi-batch.
ignore_index (int, optional) – 是否忽略某特定index对gradient的贡献,size_average = True, 忽略指定index目标的loss.
reduce (bool, optional) – False - 返回单个样本的loss, True - 按照size_average设定来计算loss