code: def initialize_weights(net):
      """
      Initialize model weights. Current Default in Pytorch (version 0.4.1) is initialization from a uniform distriubtion.
      Will expectably be changed to kaiming_uniform in future versions.
      """
      init_type = net.cf.weight_init
  
      for m in [
          module
          for module in net.modules()
          if type(module)
          in [
              nn.Conv2d,
              nn.Conv3d,
              nn.ConvTranspose2d,
              nn.ConvTranspose3d,
              nn.Linear,
          ]
      ]:
          if init_type == "xavier_uniform":
              nn.init.xavier_uniform_(m.weight.data)
              if m.bias is not None:
                  m.bias.data.zero_()
  
          elif init_type == "xavier_normal":
              nn.init.xavier_normal_(m.weight.data)
              if m.bias is not None:
                  m.bias.data.zero_()
  
          elif init_type == "kaiming_uniform":
              nn.init.kaiming_uniform_(
                  m.weight.data,
                  mode="fan_out",
                  nonlinearity=net.cf.relu,
                  a=0,
              )
              if m.bias is not None:
                  (
                      fan_in,
                      fan_out,
                  ) = nn.init._calculate_fan_in_and_fan_out(
                      m.weight.data
                  )
                  bound = 1 / np.sqrt(fan_out)
                  nn.init.uniform_(m.bias, -bound, bound)
  
          elif init_type == "kaiming_normal":
              nn.init.kaiming_normal_(
                  m.weight.data,
                  mode="fan_out",
                  nonlinearity=net.cf.relu,
                  a=0,
              )
              if m.bias is not None:
                  (
                      fan_in,
                      fan_out,
                  ) = nn.init._calculate_fan_in_and_fan_out(
                      m.weight.data
                  )
                  bound = 1 / np.sqrt(fan_out)
                  nn.init.normal_(m.bias, -bound, bound)
  
imports: import numpy
  import scipy.misc
  import scipy.ndimage
  import torch
  from torch.autograd import Variable
  import torch.nn
label_desc: Use image node_id 23 for calling a global function with example usage: initialize_weights(net) without return types