0和1, 80和81的loss是一样的。
两个分布一样,loss为0
#双方都有0,会减少loss
x值不用在 0-1之间
求和: size_average=False
mseloss测试
import torch
conf_mask = torch.FloatTensor([0.0, 1.0, 0.0, 1.0, 1.0])
conf_data = torch.FloatTensor([0.1, 0.9, 0.0, 0.2, 0.2])
loss_fn = torch.nn.MSELoss() # reduce=False, size_average=False)
x= loss_fn(conf_mask, conf_data).item()
print('-----0&1',x)
x1= loss_fn(conf_mask[conf_mask == 0], conf_data[conf_mask == 0]).item()
print('-------0',x1)
x2= loss_fn( conf_mask[conf_mask == 1], conf_data[conf_mask == 1]).item()
print('-------1',x2)
x2= loss_fn(torch.FloatTensor([0.0, 1.0, 0.0, 1.0, 1.0,0]), torch.FloatTensor([0.1, 0.9, 0.0, 0.2, 0.2,0])).item()
print('---add 0',x2)
x2= loss_fn(torch.FloatTensor([0.0, 1.0, 0.0, 1.0, 1.0,0,0]), torch.FloatTensor([0.1, 0.9, 0.0, 0.2, 0.2,0,0])).item()
print('add 0×2',x2)