class SegmentationLosses(nn.CrossEntropyLoss):
"""2D Cross Entropy Loss with Auxilary Loss"""
def __init__(self, se_loss=False, se_weight=0.2, nclass=-1, aux_num=2,
aux=False, aux_weight=0.1, weight=None,
ignore_index=-1):
super(SegmentationLosses, self).__init__(weight, None, ignore_index)
self.se_loss = se_loss
self.aux = aux
self.nclass = nclass
self.se_weight = se_weight
def forward(self, *inputs):
pred1, target = tuple(inputs)
print(pred1.size())
print(target.size())
a = super(SegmentationLosses, self).forward(pred1, target)
print(a)
return a
下面是我debeg截图,显示pred1, target这两个参数的size是不一样的,为什么没有报错呢?
最后一层维度是1的,是可以看成向量的。能正确预测