(p, prob=True, mean=True)
| 2 | import torch.nn.functional as F |
| 3 | |
| 4 | def entropy(p, prob=True, mean=True): |
| 5 | if prob: |
| 6 | p = F.softmax(p) |
| 7 | en = -torch.sum(p * torch.log(p+1e-5), 1) |
| 8 | if mean: |
| 9 | return torch.mean(en) |
| 10 | else: |
| 11 | return en |
| 12 | |
| 13 | |
| 14 | def ova_loss(out_open, label): |
nothing calls this directly
no outgoing calls
no test coverage detected