UserWarning: size_average and reduce args will be deprecated, please use reduction=‘sum‘ instead. wa

此报错为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')


其它损失函数更改方法类似

你可能感兴趣的:(pytorch,cnn,python)