MCPcopy Create free account
hub / github.com/huggingface/transformers / copy_layers

Function copy_layers

examples/seq2seq/initialization_utils.py:17–20  ·  view source on GitHub ↗
(teacher_layers: nn.ModuleList, student_layers: nn.ModuleList, layers_to_copy: List)

Source from the content-addressed store, hash-verified

15
16
17def copy_layers(teacher_layers: nn.ModuleList, student_layers: nn.ModuleList, layers_to_copy: List) -> None:
18 layers_to_copy = nn.ModuleList([l for i, l in enumerate(teacher_layers) if i in layers_to_copy])
19 assert len(student_layers) == len(layers_to_copy), f"{len(student_layers)} != {len(layers_to_copy)}"
20 student_layers.load_state_dict(layers_to_copy.state_dict())

Callers 3

copy_to_studentMethod · 0.90
copy_t5_to_studentMethod · 0.90
copy_decoder_layersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected