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

Function scaled_init_method

model/modeling_bert.py:49–56  ·  view source on GitHub ↗

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

(mean, std, num_layers)

Source from the content-addressed store, hash-verified

47
48
49def scaled_init_method(mean, std, num_layers):
50 """Init method based on N(0, sigma/sqrt(2*num_layers)."""
51 std = std / math.sqrt(2.0 * num_layers)
52
53 def init_(tensor):
54 return torch.nn.init.normal_(tensor, mean=mean, std=std)
55
56 return init_
57
58
59def bert_extended_attention_mask(attention_mask):

Callers 2

__init__Method · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected