MCPcopy Create free account
hub / github.com/CompVis/diff2flow / __init__

Method __init__

diff2flow/lora.py:84–107  ·  view source on GitHub ↗
(
        self,
        in_channels: int,
        out_channels: int,
        kernel_size: Union[int, Tuple[int, int]],
        stride: Union[int, Tuple[int, int]],
        padding: Union[int, Tuple[int, int]],
        rank: int = None,
        lora_scale: float = 1.0,
    )

Source from the content-addressed store, hash-verified

82
83class LoRAConv(nn.Module):
84 def __init__(
85 self,
86 in_channels: int,
87 out_channels: int,
88 kernel_size: Union[int, Tuple[int, int]],
89 stride: Union[int, Tuple[int, int]],
90 padding: Union[int, Tuple[int, int]],
91 rank: int = None,
92 lora_scale: float = 1.0,
93 ):
94 super().__init__()
95
96 # self.lora_scale = alpha / rank
97 self.lora_scale = lora_scale
98
99 self.W = nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding)
100 for p in self.W.parameters():
101 p.requires_grad_(False)
102
103 self.A = nn.Conv2d(in_channels, rank, kernel_size, stride, padding, bias=False)
104 self.B = nn.Conv2d(rank, out_channels, kernel_size=1, stride=1, padding=0, bias=False)
105
106 nn.init.zeros_(self.B.weight)
107 nn.init.kaiming_normal_(self.A.weight, a=1)
108
109 def forward(self, x):
110 """

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected