浏览代码

return None if no ex_bias

Kohaku-Blueleaf 2 年之前
父节点
当前提交
a2b8305096
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 3 3
      extensions-builtin/Lora/network.py
  2. 1 1
      extensions-builtin/Lora/networks.py

+ 3 - 3
extensions-builtin/Lora/network.py

@@ -145,10 +145,10 @@ class NetworkModule:
         if orig_weight.size().numel() == updown.size().numel():
         if orig_weight.size().numel() == updown.size().numel():
             updown = updown.reshape(orig_weight.shape)
             updown = updown.reshape(orig_weight.shape)
 
 
-        if ex_bias is None:
-            ex_bias = 0
+        if ex_bias is not None:
+            ex_bias = ex_bias * self.multiplier()
 
 
-        return updown * self.calc_scale() * self.multiplier(), ex_bias * self.multiplier()
+        return updown * self.calc_scale() * self.multiplier(), ex_bias
 
 
     def calc_updown(self, target):
     def calc_updown(self, target):
         raise NotImplementedError()
         raise NotImplementedError()

+ 1 - 1
extensions-builtin/Lora/networks.py

@@ -322,7 +322,7 @@ def network_apply_weights(self: Union[torch.nn.Conv2d, torch.nn.Linear, torch.nn
                         updown = torch.nn.functional.pad(updown, (0, 0, 0, 0, 0, 5))
                         updown = torch.nn.functional.pad(updown, (0, 0, 0, 0, 0, 5))
 
 
                     self.weight += updown
                     self.weight += updown
-                    if getattr(self, 'bias', None) is not None:
+                    if ex_bias is not None and getattr(self, 'bias', None) is not None:
                         self.bias += ex_bias
                         self.bias += ex_bias
                     continue
                     continue