(self, x, y)
| 23 | self.reduction = reduction |
| 24 | |
| 25 | def forward(self, x, y): |
| 26 | loss = torch.sum(-y * F.log_softmax(x, dim=-1), dim=-1) |
| 27 | if self.reduction == "mean": |
| 28 | return loss.mean() |
| 29 | elif self.reduction == "none": |
| 30 | return loss |
| 31 | else: |
| 32 | raise NotImplementedError |
| 33 | |
| 34 | |
| 35 | _LOSSES = { |
nothing calls this directly
no outgoing calls
no test coverage detected