錯誤提示:
為pytorch不同版本進行更新迭代時引起的警告,某些參數被取代了
修正:
criterion = torch.nn.BCELoss(size_average=True) 改為: criterion = torch.nn.BCELoss(reduction='mean')
criterion = torch.nn.BCELoss(size_average=False) 改為: criterion = torch.nn.BCELoss(reduction='sum')
其它損失函數更改方法類似
原代碼:
test_loss += F.nll_loss(output, target, size_average=False).item()
修正代碼:
test_loss += F.nll_loss(output, target, reduction='sum').item()