| 73 | """ |
| 74 | |
| 75 | def __init__(self, classes, weight=None, ignore_index=cfg.DATASET.IGNORE_LABEL, |
| 76 | norm=False, upper_bound=1.0, fp16=False): |
| 77 | super(ImageBasedCrossEntropyLoss2d, self).__init__() |
| 78 | logx.msg("Using Per Image based weighted loss") |
| 79 | self.num_classes = classes |
| 80 | self.nll_loss = nn.NLLLoss(weight, reduction='mean', |
| 81 | ignore_index=ignore_index) |
| 82 | self.norm = norm |
| 83 | self.upper_bound = upper_bound |
| 84 | self.batch_weights = cfg.BATCH_WEIGHTING |
| 85 | self.fp16 = fp16 |
| 86 | |
| 87 | def calculate_weights(self, target): |
| 88 | """ |