(self, inputs, targets, do_rmi=None)
| 100 | return hist |
| 101 | |
| 102 | def forward(self, inputs, targets, do_rmi=None): |
| 103 | |
| 104 | if self.batch_weights: |
| 105 | weights = self.calculate_weights(targets) |
| 106 | self.nll_loss.weight = weights |
| 107 | |
| 108 | loss = 0.0 |
| 109 | for i in range(0, inputs.shape[0]): |
| 110 | if not self.batch_weights: |
| 111 | weights = self.calculate_weights(targets) |
| 112 | if self.fp16: |
| 113 | weights = weights.half() |
| 114 | self.nll_loss.weight = weights |
| 115 | |
| 116 | loss += self.nll_loss(F.log_softmax(inputs[i].unsqueeze(0), dim=1), |
| 117 | targets[i].unsqueeze(0),) |
| 118 | return loss |
| 119 | |
| 120 | |
| 121 | class CrossEntropyLoss2d(nn.Module): |
nothing calls this directly
no test coverage detected