(target_module: torch.nn.Linear, sigma: float)
| 36 | |
| 37 | |
| 38 | def 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 | |
| 47 | def replace_module_weights(target_module, new_weight): |
no outgoing calls
no test coverage detected