MCPcopy Create free account
hub / github.com/CERT-Lab/lora-sb / init_module_weights

Function init_module_weights

utils/initialization_utils.py:38–44  ·  view source on GitHub ↗
(target_module: torch.nn.Linear, sigma: float)

Source from the content-addressed store, hash-verified

36
37
38def init_module_weights(target_module: torch.nn.Linear, sigma: float):
39 # Initialize weights with Gaussian distribution
40 torch.nn.init.normal_(target_module.weight, mean=0, std=sigma)
41 if hasattr(target_module, "bias"):
42 # Set bias to zeros
43 if target_module.bias is not None:
44 torch.nn.init.zeros_(target_module.bias)
45
46
47def replace_module_weights(target_module, new_weight):

Callers 2

find_and_initialize_gradFunction · 0.85
find_and_initializeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected