MCPcopy Create free account
hub / github.com/THUDM/GLM / scaled_init_method

Function scaled_init_method

mpu/transformer.py:593–600  ·  view source on GitHub ↗

Init method based on N(0, sigma/sqrt(2*num_layers).

(sigma, num_layers)

Source from the content-addressed store, hash-verified

591
592
593def scaled_init_method(sigma, num_layers):
594 """Init method based on N(0, sigma/sqrt(2*num_layers)."""
595 std = sigma / math.sqrt(2.0 * num_layers)
596
597 def init_(tensor):
598 return torch.nn.init.normal_(tensor, mean=0.0, std=std)
599
600 return init_
601
602
603class GPT2ParallelTransformer(torch.nn.Module):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected