MCPcopy Create free account
hub / github.com/SooLab/CGFormer / l2norm

Function l2norm

model/layers.py:7–13  ·  view source on GitHub ↗

L2-normalize columns of X

(X, dim=-1, eps=1e-12)

Source from the content-addressed store, hash-verified

5from timm.models.layers import trunc_normal_
6
7def l2norm(X, dim=-1, eps=1e-12):
8 """
9 L2-normalize columns of X
10 """
11 norm = torch.pow(X, 2).sum(dim=dim, keepdim=True).sqrt() + eps
12 X = torch.div(X, norm)
13 return X
14
15
16class Mlp(nn.Module):

Callers 1

forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected