MCPcopy Create free account
hub / github.com/TorchSSL/TorchSSL / _l2_normalize

Function _l2_normalize

models/vat/vat_utils.py:21–25  ·  view source on GitHub ↗
(d)

Source from the content-addressed store, hash-verified

19 return -(p*F.log_softmax(ul_y, dim=1)).sum(dim=1).mean(dim=0)
20
21def _l2_normalize(d):
22
23 d = d.numpy()
24 d /= (np.sqrt(np.sum(d ** 2, axis=(1, 2, 3))).reshape((-1, 1, 1, 1)) + 1e-16)
25 return torch.from_numpy(d)
26
27def kl_div_with_logit(q_logit, p_logit):
28

Callers 1

vat_lossFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected