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

Function init_net

pix2pix/models/networks.py:101–116  ·  view source on GitHub ↗

Initialize a network: 1. register CPU/GPU device (with multi-GPU support); 2. initialize the network weights Parameters: net (network) -- the network to be initialized init_type (str) -- the name of an initialization method: normal | xavier | kaiming | orthogonal

(net, init_type='normal', init_gain=0.02, gpu_ids=[])

Source from the content-addressed store, hash-verified

99
100
101def init_net(net, init_type='normal', init_gain=0.02, gpu_ids=[]):
102 """Initialize a network: 1. register CPU/GPU device (with multi-GPU support); 2. initialize the network weights
103 Parameters:
104 net (network) -- the network to be initialized
105 init_type (str) -- the name of an initialization method: normal | xavier | kaiming | orthogonal
106 gain (float) -- scaling factor for normal, xavier and orthogonal.
107 gpu_ids (int list) -- which GPUs the network runs on: e.g., 0,1,2
108
109 Return an initialized network.
110 """
111 if len(gpu_ids) > 0:
112 assert(torch.cuda.is_available())
113 net.to(gpu_ids[0])
114 net = torch.nn.DataParallel(net, gpu_ids) # multi-GPUs
115 init_weights(net, init_type, init_gain=init_gain)
116 return net
117
118
119def define_G(input_nc, output_nc, ngf, netG, norm='batch', use_dropout=False, init_type='normal', init_gain=0.02, gpu_ids=[]):

Callers 2

define_GFunction · 0.85
define_DFunction · 0.85

Calls 2

init_weightsFunction · 0.85
toMethod · 0.80

Tested by

no test coverage detected