MCPcopy Create free account
hub / github.com/VisionLearningGroup/OVANet / entropy

Function entropy

utils/loss.py:4–11  ·  view source on GitHub ↗
(p, prob=True, mean=True)

Source from the content-addressed store, hash-verified

2import torch.nn.functional as F
3
4def 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
14def ova_loss(out_open, label):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected