MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / fix_key

Function fix_key

examples/pytorch/decoding/utils/translation_model.py:191–196  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

189 if checkpoint is not None:
190 # This preserves backward-compat for models using customed layernorm
191 def fix_key(s):
192 s = re.sub(r'(.*)\.layer_norm((_\d+)?)\.b_2',
193 r'\1.layer_norm\2.bias', s)
194 s = re.sub(r'(.*)\.layer_norm((_\d+)?)\.a_2',
195 r'\1.layer_norm\2.weight', s)
196 return s
197
198 checkpoint['model'] = {fix_key(k): v
199 for k, v in checkpoint['model'].items()}

Callers 1

build_base_modelFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected