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

Function get_norm_layer

pix2pix/models/networks.py:18–35  ·  view source on GitHub ↗

Return a normalization layer Parameters: norm_type (str) -- the name of the normalization layer: batch | instance | none For BatchNorm, we use learnable affine parameters and track running statistics (mean/stddev). For InstanceNorm, we do not use learnable affine parameters. We

(norm_type='instance')

Source from the content-addressed store, hash-verified

16
17
18def get_norm_layer(norm_type='instance'):
19 """Return a normalization layer
20
21 Parameters:
22 norm_type (str) -- the name of the normalization layer: batch | instance | none
23
24 For BatchNorm, we use learnable affine parameters and track running statistics (mean/stddev).
25 For InstanceNorm, we do not use learnable affine parameters. We do not track running statistics.
26 """
27 if norm_type == 'batch':
28 norm_layer = functools.partial(nn.BatchNorm2d, affine=True, track_running_stats=True)
29 elif norm_type == 'instance':
30 norm_layer = functools.partial(nn.InstanceNorm2d, affine=False, track_running_stats=False)
31 elif norm_type == 'none':
32 def norm_layer(x): return Identity()
33 else:
34 raise NotImplementedError('normalization layer [%s] is not found' % norm_type)
35 return norm_layer
36
37
38def get_scheduler(optimizer, opt):

Callers 2

define_GFunction · 0.85
define_DFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected