MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / init_func

Method init_func

inpaint/networks.py:19–36  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

17 '''
18
19 def init_func(m):
20 classname = m.__class__.__name__
21 if hasattr(m, 'weight') and (classname.find('Conv') != -1 or classname.find('Linear') != -1):
22 if init_type == 'normal':
23 nn.init.normal_(m.weight.data, 0.0, gain)
24 elif init_type == 'xavier':
25 nn.init.xavier_normal_(m.weight.data, gain=gain)
26 elif init_type == 'kaiming':
27 nn.init.kaiming_normal_(m.weight.data, a=0, mode='fan_in')
28 elif init_type == 'orthogonal':
29 nn.init.orthogonal_(m.weight.data, gain=gain)
30
31 if hasattr(m, 'bias') and m.bias is not None:
32 nn.init.constant_(m.bias.data, 0.0)
33
34 elif classname.find('BatchNorm2d') != -1:
35 nn.init.normal_(m.weight.data, 1.0, gain)
36 nn.init.constant_(m.bias.data, 0.0)
37
38 self.apply(init_func)
39

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected