MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / __init__

Method __init__

diffusers/src/diffusers/models/lora.py:196–220  ·  view source on GitHub ↗
(
        self,
        in_features: int,
        out_features: int,
        rank: int = 4,
        network_alpha: Optional[float] = None,
        device: Optional[Union[torch.device, str]] = None,
        dtype: Optional[torch.dtype] = None,
    )

Source from the content-addressed store, hash-verified

194 """
195
196 def __init__(
197 self,
198 in_features: int,
199 out_features: int,
200 rank: int = 4,
201 network_alpha: Optional[float] = None,
202 device: Optional[Union[torch.device, str]] = None,
203 dtype: Optional[torch.dtype] = None,
204 ):
205 super().__init__()
206
207 deprecation_message = "Use of `LoRALinearLayer` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`."
208 deprecate("LoRALinearLayer", "1.0.0", deprecation_message)
209
210 self.down = nn.Linear(in_features, rank, bias=False, device=device, dtype=dtype)
211 self.up = nn.Linear(rank, out_features, bias=False, device=device, dtype=dtype)
212 # This value has the same meaning as the `--network_alpha` option in the kohya-ss trainer script.
213 # See https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md#execute-learning
214 self.network_alpha = network_alpha
215 self.rank = rank
216 self.out_features = out_features
217 self.in_features = in_features
218
219 nn.init.normal_(self.down.weight, std=1 / rank)
220 nn.init.zeros_(self.up.weight)
221
222 def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
223 orig_dtype = hidden_states.dtype

Callers 4

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 1

deprecateFunction · 0.85

Tested by

no test coverage detected