MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / NormedLinear

Function NormedLinear

roach/models/torch_util.py:7–15  ·  view source on GitHub ↗

nn.Linear but with normalized fan-in init

(*args, scale=1.0, dtype=th.float32, **kwargs)

Source from the content-addressed store, hash-verified

5
6
7def NormedLinear(*args, scale=1.0, dtype=th.float32, **kwargs):
8 """
9 nn.Linear but with normalized fan-in init
10 """
11 out = nn.Linear(*args, **kwargs)
12 out.weight.data *= scale / out.weight.norm(dim=1, p=2, keepdim=True)
13 if kwargs.get("bias", True):
14 out.bias.data *= 0
15 return out
16
17
18def NormedConv2d(*args, scale=1, **kwargs):

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected