def forward(self, input, target):
    smooth = 0.01
    batch_size = input.size(0)
    input = F.softmax(input[:, self.class_ids], dim=1).view(batch_size, len(self.class_ids), (- 1))
    target = self.one_hot_encoder(target).contiguous().view(batch_size, self.n_classes, (- 1))
    target = target[:, self.class_ids, :]
    inter = (torch.sum((input * target), 2) + smooth)
    union = ((torch.sum(input, 2) + torch.sum(target, 2)) + smooth)
    score = torch.sum(((2.0 * inter) / union))
    score = (1.0 - (score / (float(batch_size) * float(self.n_classes))))
    return score
def forward(self, input, target):
    smooth = 0.01
    batch_size = input.size(0)
    input = F.softmax(input[:, self.class_ids], dim=1).view(batch_size, len(self.class_ids), (- 1))
    target = self.one_hot_encoder(target).contiguous().view(batch_size, self.n_classes, (- 1))
    target = target[:, self.class_ids, :]
    inter = (torch.sum((input * target), 2) + smooth)
    union = ((torch.sum(input, 2) + torch.sum(target, 2)) + smooth)
    score = torch.sum(((2.0 * inter) / union))
    score = (1.0 - (score / (float(batch_size) * float(self.n_classes))))
    return score