Files
InvokeAI/invokeai/backend/flux/controlnet/zero_module.py
2024-10-09 14:17:42 +00:00

13 lines
258 B
Python

from typing import TypeVar
import torch
T = TypeVar("T", bound=torch.nn.Module)
def zero_module(module: T) -> T:
"""Initialize the parameters of a module to zero."""
for p in module.parameters():
torch.nn.init.zeros_(p)
return module