mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-11 15:47:01 -07:00
SAEHD: added 'dfuhd' and 'liaeuhd' archi
This commit is contained in:
parent
e5f736680d
commit
eddebedcf6
5 changed files with 190 additions and 155 deletions
31
core/leras/layers/ScaleAdd.py
Normal file
31
core/leras/layers/ScaleAdd.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from core.leras import nn
|
||||
tf = nn.tf
|
||||
|
||||
class ScaleAdd(nn.LayerBase):
|
||||
def __init__(self, ch, dtype=None, **kwargs):
|
||||
if dtype is None:
|
||||
dtype = nn.floatx
|
||||
self.dtype = dtype
|
||||
self.ch = ch
|
||||
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def build_weights(self):
|
||||
self.weight = tf.get_variable("weight",(self.ch,), dtype=self.dtype, initializer=tf.initializers.zeros() )
|
||||
|
||||
def get_weights(self):
|
||||
return [self.weight]
|
||||
|
||||
def forward(self, inputs):
|
||||
if nn.data_format == "NHWC":
|
||||
shape = (1,1,1,self.ch)
|
||||
else:
|
||||
shape = (1,self.ch,1,1)
|
||||
|
||||
weight = tf.reshape ( self.weight, shape )
|
||||
|
||||
x0, x1 = inputs
|
||||
x = x0 + x1*weight
|
||||
|
||||
return x
|
||||
nn.ScaleAdd = ScaleAdd
|
Loading…
Add table
Add a link
Reference in a new issue